Grouping JUnit tests

前端 未结 7 1903
[愿得一人]
[愿得一人] 2020-11-27 04:27

Is there any way to group tests in JUnit, so that I can run only some groups?

Or is it possible to annotate some tests and then globally disable them?

I\'m u

7条回答
  •  死守一世寂寞
    2020-11-27 04:38

    Try JUnit Test Groups. From documentation :

    @TestGroup("integration")
    public class MyIntegrationTest {
       @ClassRule
       public static TestGroupRule rule = new TestGroupRule();
    
       ...
    }
    
    • Execute a simple test group: -Dtestgroup=integration
    • Execute multiple test groups: -Dtestgroup=group1,group2
    • Execute all test groups: -Dtestgroup=all

提交回复
热议问题