Are there any best practices to get Junit execute a function once in a test file , and it should also not be static.
like @BeforeClass
on non static fun
Easily use @BeforeAllMethods
/@AfterAllMethods
annotations to run a method inside the instance context (non-static), where all injected values will be available.
There is a special testing library for this:
https://mvnrepository.com/artifact/org.bitbucket.radistao.test/before-after-spring-test-runner/0.1.0
https://bitbucket.org/radistao/before-after-spring-test-runner/
The only limitation: works only for Spring testing.
(I'm the developer of this testing library)