Why TestInstance(PER_CLASS) solve static @BeforeAll

Viewed 600

I have read documentation, there is no need to explain, how we can access non-static felds in BeforeAll method etc. I am looking for an answer - why TestInstance(PER_CLASS) solve static in the method signature BeforeAll method? In other words - how does it internally works? There is no explaination about it in official docs, just said

@BeforeAll methods must have a void return type, must not be private, and must be static by default. Consequently, @BeforeAll methods are not supported in @Nested test classes or as interface default methods unless the test class is annotated with @TestInstance(Lifecycle.PER_CLASS)

And that is all. It is not clear, not obvious. Suppose, I do not understand something.

0 Answers
Related