【发布时间】:2018-03-03 09:06:27
【问题描述】:
我的问题实际上与How do I tell Maven and TestNG to run a specific test class and suite.xml file? 重复,但我不明白接受的答案,所以再次询问。
我有同样的问题,当我尝试使用 clean test -DsuiteFile=Suites\Jquery.xml 运行特定套件时,它运行该套件很好。 clean test -Dtest=WebGuru99_2 也运行该测试类,但是当我尝试执行 clean test -DsuiteFile=Suites\Jquery.xml -Dtest=WebGuru99_2 时,它运行该类,但它现在不依赖于套件文件。我可以在这里提供任何套件文件,它将运行相同的测试类,这违背了拥有套件文件的目的。
POM.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<suiteFile></suiteFile>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.35.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.35.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteFile}</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
【问题讨论】:
-
我相信我们不能这样做,因为它违背了拥有测试套件的目的。如果我们必须这样做,我们必须在代码中明确处理要执行哪个类。但不确定我是否正确。