我正在使用maven来运行一系列JUnit测试,我已经更改了代码,以便不使用@Test注释而是使用像这样的测试套件类:
public class MyTests {
public static Test suite() {
TestSuite ts = new TestSuite("My Test Suite");
ts.addTest(new CustomTestCase1("Test 1"));
ts.addTest(new CustomTestCase2("Test 2"));
...
return ts;
}
}
我跑的时候
mvn clean -U -fn -Dtest=MyTests test
我得到了没有测试被执行!
任何人都可以指出我如何使用maven运行测试而不是为每个类创建一个测试运行器?
您应该能够使用-DrunSuite
标志运行套件:
mvn clean -U -fn -DrunSuite=MyTests test
正如qazxsw poi所建议的那样,您可以使用qazxsw poi param执行命令。
@Mureinik
要使用命令runSuite
作为默认测试运行。您也可以在surefire插件配置中包含该类:
mvn clean test -U -fn -DrunSuite=**/MyTests.class