I want to have a @BeforeClass method in my springBootTest, which should be static and declared in "companion object".
@RunWith(SpringRunner::class)
@SpringBootTest
@ActiveProfiles("test")
open class MyTest {
companion object {
    @Autowired
    lateinit var repo: MyRepository
    @BeforeClass
    @JvmStatic
    fun X() {
        user = User()
        repo.save(user)
    }
}
On the other hand I should use some Autowired components in this method, but as mentioned here is not possible in static context and I got this error:
lateinit property repo has not been initialized
Any suggestion about how should I handle this situation?
 
     
    