我正在将外部junit.framework.TestSuite集成到使用Maven和JUnit4构建的库中。使用JUnit4批注开始进行典型的测试(如果不是全部测试)。如何将junit.framework.TestSuite合并到此现有测试代码库中?

到目前为止,这是我尝试过的:

public class JSR330Tck {
    @Test
    public junit.framework.Test suite(){
        Car car = Factories.get(CarFactory.class).buildCar();
        return Tck.testsFor(car, false, true);
    }
}


或者通过使用静态suite()方法定义它:

public class JSR330Tck {
    public static junit.framework.Test suite(){
        Car car = Factories.get(CarFactory.class).buildCar();
        return Tck.testsFor(car, false, true);
    }
}


这两个都不是通过Maven surefire插件触发的。

最佳答案

我假设您的测试类不是基于与maven-surefire-plugin关联的test的命名约定来命名的

includes>
 <include>**/*Test*.java</include>
 <include>**/*Test.java</include>
 <include>**/*TestCase.java</include>
</includes>


除此之外,您不应该使用TestSuites,因为surefire-plugin已经可以解决这个问题。因此,通常无需分别定义套件。

08-06 02:10
查看更多