【发布时间】:2020-01-09 02:12:18
【问题描述】:
我正在尝试使用 Flyway 测试扩展库,它的说明之一是添加:
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class,
FlywayTestExecutionListener.class })
所以在 Kotlin 中我有一些类似的东西:
@RunWith(SpringRunner::class)
@TestExecutionListeners(DependencyInjectionTestExecutionListener::class,
FlywayTestExecutionListener::class )
class MyControllerTest {
@Autowired
lateinit var dataSource : DataSource
}
但由于某种原因,当我尝试在该类中运行测试时,我收到一条错误消息,指出 lateinit 属性尚未初始化。
我需要做什么/做一些特别的事情才能让它发挥作用吗?
【问题讨论】:
标签: spring-boot kotlin dependency-injection junit4