【发布时间】:2018-07-23 01:37:17
【问题描述】:
我正在使用 maven 3.5.4、maven-surefire-plugin 2.19(我也尝试了 maven-surefire-plugin 2.22 - 结果相同)。 这是我的 POM 的构建部分:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<inherited>true</inherited>
<configuration>
<parallel>classes</parallel>
<threadCount>20</threadCount>
</configuration>
<executions>
<execution>
<id>default-test</id>
<configuration>
<excludedGroups>switch-enabled</excludedGroups>
</configuration>
</execution>
<execution>
<id>other-tests</id>
<configuration>
<groups>switch-enabled</groups>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我有两组需要单独运行的单元测试(由于静态布尔变量,因此我设置了一个 TestNG 组,并在该组中设置了所有需要打开开关的测试)。
Surefire 仅运行“默认测试”执行并忽略其他执行。我也尝试了以下方法,但也没有用 - 没有运行测试:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<inherited>true</inherited>
<configuration>
<parallel>classes</parallel>
<threadCount>20</threadCount>
</configuration>
<executions>
<execution>
<id>default-test</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>true-tests</id>
<configuration>
<groups>switch-enabled</groups>
</configuration>
</execution>
<execution>
<id>false-tests</id>
<configuration>
<excludedGroups>switch-enabled</excludedGroups>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我做错了什么?
【问题讨论】:
-
您是否尝试删除
default-test执行?鉴于您无论如何都在跳过它。 -
@dryleaf 是的,然后所有测试都在一次执行中运行,作为默认测试:(
标签: maven testng maven-surefire-plugin