这是我的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>
我需要做什么 - 从Windows上的cmd运行某个测试套件。从项目目录开始,我尝试使用不同的命令变体:
mvn test -Dsurefire.suiteXmlFile=wwwRegression
mvn test -Dsuite=wwwRegression
mvn surefire:test -DsuiteXmlFile=wwwRegression
但是所有测试套件都在执行。 有没有人有任何想法如何运行某个测试套件?
答案 0 :(得分:0)
您必须在pom文件中设置一个属性才能通过命令提示符。
修改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>
您可以使用
运行测试mvn -U clean install -DtestngFiles = src / test / resources / wwwRegression.xml
注意:Surefire可以将多个testNG XML文件作为逗号分隔值。