Kotlin SpringBoot Junit TestCase with @BeforeClass


when i use @BeforeClass in kotlin and spring boot

i have some problem…

class FSServiceTest : ApplicationTest() {

    lateinit var fsService: FSService

    companion object {

        fun setup() {
            fsService.del("")//can`t find fsService


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.