gpt4 book ai didi

java - 如何在单线程中仅运行 Maven Surefire 插件中的一个 TestNG 类?

转载 作者:行者123 更新时间:2023-12-01 10:50:46 24 4
gpt4 key购买 nike

我使用 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>
  1. 如果我使用<suiteXmlFiles> ,那么aspectj将看不到我的测试,并且我需要在xml中编写所有测试类(我不想这样做,因为我使用aspectj)
  2. 如果我设置 <parallel>在 maven-surefire-plagin 中 - 所有类中的所有方法都是并行的。

也许我可以包含一个类来并行?

最佳答案

您可以将 mvn test -Dtest=classname 与上面的当前 pom 声明一起使用。

这将并行触发上述类中的测试方法。

关于java - 如何在单线程中仅运行 Maven Surefire 插件中的一个 TestNG 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33926425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com