简体   繁体   中英

How keep spring context loaded between test runs in Intellij Idea?

Spring-test provides annotation for loading spring context during test runs. For example there is a org.springframework.test.context.junit4.SpringJUnit4ClassRunner junit runner class and org.springframework.test.context.ContextConfiguration annotation for specify context loading. For integration tests context loading can be quite long and during debugging it is needed to run same test dozen times until it "lose" all it's errors. Is there a way to do so without loading context multiple times? For example I finished debugging context loading, then run that context and start running test in intellij idea? Is that possible with Intellij Idea?

Long time ago without answer, which is strange, and this is very important to know because it can save a lot of resources and time.

If you have one class with annotation

@SpringBootTest
public class IntegrationTest

And you extend it to all your Test classes context will be loaded only once

public class ServiceIntegationTest extends IntegrationTest

All tests in this class will use same context. Also all classes that extend this class will reuse same context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM