How to test Classes with @ConfigurationProperties and @Autowired

后端 未结 5 902
感情败类
感情败类 2020-12-09 07:52

I want to test small parts of the application that rely on properties loaded with @Autowired and @ConfigurationProperties. I am looking for a solut

5条回答
  •  囚心锁ツ
    2020-12-09 08:02

    you can actually just add @EnableConfigurationProperties to your @SpringBootTest directly.
    eg:

    @ActiveProfiles("test")
    @RunWith(SpringRunner.class)
    @SpringBootTest(classes = TestConfiguration.class)
    @EnableConfigurationProperties
    ...
    

提交回复
热议问题