Run all JUnit tests indepentently in Eclipse, reloading Spring context each time

后端 未结 1 543
执笔经年
执笔经年 2020-12-22 03:58

Goal: Find a way in Eclipse to execute all the tests in a JUnit class which reloads the Spring context before each test, instead of just once.

Scenario: I inherited

1条回答
  •  天涯浪人
    2020-12-22 04:41

    You can use @DirtiesContext in your test class:

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(classes = { MyConf.class })
    @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
    public void MyTestClass {
    

    This will reload the context after each test method.

    0 讨论(0)
提交回复
热议问题