HunJeong
07/20/2021, 12:47 AM...
@ContextConfiguration(classes = [(Components::class)])
class SpringExtensionTest : WordSpec() {
override fun isolationMode() = IsolationMode.InstancePerTest // or InstancePerLeaf
override fun extensions() = listOf(SpringExtension)
@Autowired
private var service: UserService? = null
init {
"SpringExtension" should {
"have autowired the service" {
service?.repository?.findUser()?.name shouldBe "system_user"
}
...
‘have autowired the service’ test is broken
---
but I change this code to
...
@ContextConfiguration(classes = [(Components::class)])
class SpringListenerTest : WordSpec() {
override fun isolationMode() = IsolationMode.InstancePerTest // or InstancePerLeaf
override fun listeners() = listOf(SpringListener)
@Autowired
private var service: UserService? = null
init {
"SpringListener" should {
"have autowired the service" {
service?.repository?.findUser()?.name shouldBe "system_user"
}
...
It workssam
07/20/2021, 10:50 AMHunJeong
07/20/2021, 12:08 PMsam
07/20/2021, 12:23 PMHunJeong
07/21/2021, 2:40 AM