Kotlin SpringBoot Junit TestCase with @BeforeClass

when i use @BeforeClass in kotlin and spring boot

i have some problem…

class FSServiceTest : ApplicationTest() {

    @Autowired
    lateinit var fsService: FSService

    companion object {

        @JvmStatic
        @BeforeClass
        fun setup() {
            fsService.del("")//can`t find fsService
        }
    }
}
1 Like

Same for me. Not sure how to use @Autowired inside of a companion object.

There is a suggestion to migrate to JUnit5: spring - Kotlin - How to manage @BeforeClass static method in springBootTest - Stack Overflow

However, the problem remains.