Java Spring Boot Test: How to exclude java configuration class from test context

前端 未结 5 774
后悔当初
后悔当初 2021-01-17 07:41

I have a Java web app with spring boot

When run test I need to exclude some Java config files:

Test config (need to include when test run):

@         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 08:34

    You can use @ConditionalOnMissingClass("org.springframework.test.context.junit4.SpringJUnit4ClassRunner") in Configuration class.SpringJUnit4ClassRunner can be replaced by any class which only exits in test environment.

提交回复
热议问题