我想使用 Maven 和 TestNG 从命令行运行单个测试类
不起作用的事情:
mvn -Dtest=ClassName test
我在 pom.xml 中定义了组,而这个类不在其中一个组中。所以它基于这些理由被排除在外。
mvn -Dgroups=skipped-group test
mvn -Dsurefire.groups=skipped-group test
当配置是
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<groups>functest</groups>
</configuration>
</plugin>
在 pom.xml 中没有定义组时,参数工作正常。
同样,当surefire配置为
<configuration>
<includes>
<include>**/*UnitTest.java</include>
</includes>
</configuration>
我可以添加另一个带有-Dtest
参数的测试,但不能添加组。在任何组合中,我都可以缩小要与组一起执行的测试,但不能扩展它们。
我的配置有什么问题?有没有办法在 pom.xml 中定义的测试或组之外运行单个测试或组?
在 Ubuntu 10.04 上试用 Maven 2.2.1、TestNG 5.14.6 和 Surefire 2.7.1