我想用testng与Surefire plug-in的Maven。这个想法是用一组integrationTest
标记一些测试并运行插件两次:目标test
不包括组integrationTest
和目标integration-test
包括组integrationTest
只。如何使用Maven Surefire插件与不同的组进行测试和集成测试?
我发现一些material为两个目标运行插件和工作,但第二次运行组不起作用(没有测试执行)。
这里是我的pom.xml
的build元素的插件配置:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>integrationTest</excludedGroups>
<reportFormat>brief</reportFormat>
<trimStackTrace>true</trimStackTrace>
<useFile>false</useFile>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>integrationTest</groups>
<excludedGroups/>
<reportsDirectory>${project.build.directory}/surefire-reports/integration</reportsDirectory>
</configuration>
</execution>
</executions>
</plugin>
任何想法? mvn integration-test
运行所有的单元测试如预期(不包括组integrationTest
),但第二次试运行只是写道:
运行的TestSuite
测试运行:0,失败:0,错误:0,跳过:0,经过的时间:0.562秒
mvn test
的结果与预期的一样,测试运行并且组integrationTest
被忽略。
excludedGroups不适用于TestNG 5.14.1 - 改为使用5.14.2! – 2010-11-16 08:49:02
对于Surefire 2.18.1和JUnit 4.10,我得到错误`[ERROR]无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test(integration-test)on project example-项目:执行集成测试 目标org.apache.maven.plugins:maven-surefire-plugin:2.18.1:测试失败:分叉进程出错 [错误] java.lang.RuntimeException:无法加载类别:无`。看起来你重写的小组必须至少存在,即使它不在任何地方使用。我用`公共接口SystemTest扩展IntegrationTest`做这个,并排除*那个*类别。 – orlade 2015-01-08 22:30:04