Run all tests in Junit 4

前端 未结 7 1603
感动是毒
感动是毒 2021-02-01 15:45

I want to be able to run all tests in a project programmatically. I know Eclipse has a \"Run as JUnit test\" configuration which somehow grabs all the tests in a project and run

7条回答
  •  无人共我
    2021-02-01 16:32

    Though it does not really solve your immediate problem, I find it a very useful general practice to create suites and suites of suites, e.g. for a package something like PackageFooSuite etc. and assemble these suites in one or more suites again, like ModuleFooSuite and have one top-level suite, like AllTestsSuite. That way it's easy to run both all tests in one step as well as submodule tests for the package I'm currently working on (and have the tests run quicker than if I would always run all of them):

    @RunWith(Suite.class)
    @Suite.SuiteClasses({ PackageFooSuite.class, PackageBarSuite.class} )
    public final class AllTestsSuite {} // or ModuleFooSuite, and that in AllTests
    

提交回复
热议问题