[英]Can not run TestNG suit in Maven project
Here is my pom file for Java Selenium WebDriver Maven project: 这是Java Selenium WebDriver Maven项目的pom文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyProject</groupId>
<artifactId>TestAutomation</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/wwwRegression.xml</suiteXmlFile>
<suiteXmlFile>src/test/resources/betaRegression.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.50.1</version>
</dependency>
</dependencies>
</project>
What I need to do - run certain test suite from cmd on windows. 我需要做的-在Windows上从cmd运行某些测试套件。 From the project dir I tried to use different variations of commands: 从项目目录中,我尝试使用不同的命令变体:
mvn test -Dsurefire.suiteXmlFile=wwwRegression
mvn test -Dsuite=wwwRegression
mvn surefire:test -DsuiteXmlFile=wwwRegression
But all the time both of the test suites are executing. 但是,所有测试套件始终都在执行。 Does anybody have any ideas how to run one certain test suite ? 是否有人对如何运行某个测试套件有任何想法?
You have to set a property in the pom file to be able to pass through the command prompt. 您必须在pom文件中设置属性才能通过命令提示符。
Modify the pom file like below. 如下修改pom文件。
<properties
<testngFiles>src/test/resources/wwwRegression.xml,src/test/resources/betaRegression.xml</testngFiles>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${testngFiles}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
You can run the test by using 您可以使用来运行测试
mvn -U clean install -DtestngFiles=src/test/resources/wwwRegression.xml mvn -U全新安装-DtestngFiles = src / test / resources / wwwRegression.xml
Note: Surefire can take multiple testNG XML files as comma separated values. 注意:Surefire可以将多个testNG XML文件作为逗号分隔的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.