我正在使用JUnit Categories和ClassPathSuite,类似于
this answer中描述的设置。要概述:
public interface FastTests {
}
@RunWith(Categories.class)
@Categories.IncludeCategory(FastTests.class)
@Suite.SuiteClasses(AllTests.class)
public class FastTestSuite {
}
@RunWith(ClasspathSuite.class)
public class AllTests {
}
… AllTests使用ClasspathSuite库。
作为FastTests类别的一部分的测试类将如下所示:
@Category(FastTests.class)
public class StringUtilsTest {
// …
}
当我在我的IDE中运行“FastTestSuite”时,所有使用FastTests注释的测试都会执行,光滑:
现在,我想和蚂蚁做同样的事情。 (令我吃惊的是,我无法轻松地在这个SO上找到这个说明。)换句话说,我需要一个使用FastTests注释运行所有测试的Ant目标。
我尝试过一些简单的方法,使用< test>或< batchtest> …
…但没有运气,到目前为止。
编辑:除了IDE,它在命令行上的JUnitCore可以正常工作:
$ java -classpath “classes:WebContent/WEB-INF/lib/*” org.junit.runner.JUnitCore fi.foobar.FastTestSuite
………….
Time: 0.189
OK (13 tests)