使用JUnit 4.8和新的@Category标注,有没有办法选择Maven的Surefire插件运行的类别子集?如何在Maven中按类别运行JUnit测试?
比如我有:
@Test
public void a() {
}
@Category(SlowTests.class)
@Test
public void b() {
}
而且我想运行所有非慢速测试,如下所示:(注意-Dtest.categories是由我提出了...)。
mvn test -Dtest.categories=!SlowTests // run non-slow tests
mvn test -Dtest.categories=SlowTests // run only slow tests
mvn test -Dtest.categories=SlowTests,FastTests // run only slow tests and fast tests
mvn test // run all tests, including non-categorized
所以问题是,我不希望有创建测试套件(Maven,那么拿起所有的单元测试中,这是非常方便的项目),我想Maven来能够挑选按类别进行测试。 我想我只是编制了-Dtest.categories,所以我想知道是否有类似的设施可以使用?
参见[TestNG的混合和JUnit(http://stackoverflow.com/questions/9172820/mix-testng-junit-with-maven-surefire-plugin-version-2-11-and-higher-for-integ)了解更多详情。从maven-surefire-plugin 2.11版支持类别 – 2012-02-29 13:50:48