Currently the JUnit 5 API only allows @BeforeAll
on a method that is static.
So if I do something like this, it will not compile:
@BeforeAll
fun setup() {
MockitoAnnotations.initMocks(this)
mvc = MockMvcBuilders.standaloneSetup(controller).build()
}
In order to have a static method in Kotlin, I have to use companion object
like this:
companion object {
@JvmStatic
@BeforeAll
fun setup() {
MockitoAnnotations.initMocks(this)
mvc = MockMvcBuilders.standaloneSetup(smsController).build()
}
}
This will compile, but I don't have access to variables from the parent class. So what would be the idiomatic way to invoke JUnit 5 @BeforeAll
with Kotlin?