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
Just use @BeforeClass:
@BeforeClass
public static void init() {
}
It doesn't make sense for init to be non-static because each test is run in a separate instance. The instance
that init is run on would not match the instance of any test.
The only reason that you might want it to be non-static is to override it in subclasses, but you can do this
with static methods too. Just use the same name, and only the subclass init method will be called.