我在我的 pom 中定义了以下配置,以确保使用 TestNg:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>${skip-all-tests}</skipTests>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skip-unit-tests}</skip>
<groups>unit</groups>
<excludedGroups>integration</excludedGroups>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skip-integration-tests}</skip>
<groups>integration</groups>
<excludedGroups>unit</excludedGroups>
</configuration>
</execution>
</executions>
</plugin>
但似乎这两次执行之前总是有一个“默认测试”运行,它似乎运行每个 @test 注释方法(至少我是这么认为的)。
--- maven-surefire-plugin:2.12:test (default-test) @ my-project
例如在项目上运行“mvn test”,会执行两次测试。“默认测试”和“单元测试”。
有人可以向我解释一下吗?可以禁用或控制它(配置测试的内容和不测试的内容)吗?