我使用 allure framevork + testNG 来报告测试。我想从 Maven 并行运行仅一个测试类。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<parallel>methods</parallel>
<threadCount>10</threadCount>
<!--suiteXmlFiles>
<suiteXmlFile>src/test/resources/testing.xml</suiteXmlFile>
</suiteXmlFiles-->
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
- 如果我使用
<suiteXmlFiles>
,那么aspectj将看不到我的测试,并且我需要在xml中编写所有测试类(我不想这样做,因为我使用aspectj) - 如果我设置
<parallel>
在 maven-surefire-plagin 中 - 所有类中的所有方法都是并行的。
也许我可以包含一个类来并行?
最佳答案
您可以将 mvn test -Dtest=classname
与上面的当前 pom 声明一起使用。
这将并行触发上述类中的测试方法。
关于java - 如何在单线程中仅运行 Maven Surefire 插件中的一个 TestNG 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33926425/