Kotlin SpringBoot Junit TestCase with @BeforeClass


#1

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
        }
    }
}

#2

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

There is a suggestion to migrate to JUnit5: https://stackoverflow.com/a/51636381/1770617

However, the problem remains.