简体   繁体   中英

Integration tests on Spring Boot: webEnvironment required?

EDIT

I also tried to add

@ContextConfiguration(loader=AnnotationConfigContextLoader.class)

as suggested in this official Spring Blog page , but nothing


I created some integration tests, that tests methods of some repositories. I found that without:

@SpringBootTest(
    webEnvironment = SpringBootTest.WebEnvironment.MOCK,
    classes = ********.class
)

the tests don't run. I tried also with WebEnvironment.NONE , but I get

java.lang.IllegalStateException: Failed to load ApplicationContext

I don't understand why the web environment is required. Is there not a way to run an integration test on repositories without running the web environment?

Finally I found out the problem is using @EnableSwagger2.Check the following link.

Spring boot service layer integration test with WebEnvironment.NONE not working

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