springboot框架: powermock 进行service的单元测试
在service上加注解@AutoConfigureTestDatabase(走配置的虚拟数据库)。但是会执行commandLineRanner实例。如何忽略commandLineRanner实例这个@component 呢?
其实很简单,在commandLineRanner实例上加注解@TestConfiguration或者@TestComponent就可以忽略。
官方文档链接:http://docs.spring.io/spring-boot/docs/1.5.1.RELEASE/reference/htmlsingle/#boot-features-testing