在所有项目中运行所有测试类

时间:2013-04-24 08:47:29

标签: java eclipse unit-testing testing junit

我有以下项目设置:

enter image description here

该应用程序由几个项目组成,每个项目都有一个测试包。这些测试包包含此特定项目的测试类以及运行此包中所有测试的TestAll class。 TestAll类看起来像这样:

@RunWith(Suite.class)
@Suite.SuiteClasses( {
    TestClass1.class,
    TestClass2.class,
    TestClassX.class

} )
public class TestAll {}

是否可以在所有项目中同时运行所有这些TestAll classes?现在我手动运行每个TestAll class,这是非常耗时的。我希望将结果保存在某处,但这是后来的问题

1 个答案:

答案 0 :(得分:0)

通过此处给出的提示解决了这个问题:Run Junit-Tests from several projects conveniently fast in Eclipse

我所做的是创建一个新项目TestAllProjects,并在构建路径中添加包含我的测试的所有项目 - >项目

完成此操作后,我在此项目中创建了TestAllClass

import path.to.package.containg.test.for.project1.testAll.*;
import path.to.package.containg.test.for.project2.testAll.*;
import path.to.package.containg.test.for.projectX.testAll.*;


@RunWith(Suite.class)
@Suite.SuiteClasses( {
    TestAllProject1.class, //Refrence to a TestAll class
    TestAllProject2.class, //Refrence to a TestAll class
    TestAllProjectX.class  //Refrence to a TestAll class

} )

public class TestAllProjects {}

现在当我运行它时,它将运行我在每个项目中创建的所有TestAll类,导致所有测试类都在运行