- Source: https: //doczhcn.gitbook.io/junit5/index/index/what-is-junit-5
Use @ Test, @ TestTemplate, @ RepeatedTest, @ BeforeAll, @ AfterAll, @ BeforeEach or @AfterEach annotated method does not return a value.
Test class and test methods are not necessarily the public.
If you would like JUnit Jupiter execute all test methods in a test case with, just use @TestInstance (Lifecycle.PER_CLASS) for your test class can be annotated. When using this mode, each test class to create a new test case. Therefore, if your test methods rely on the state stored in the instance variables, it may be necessary to reset the state or @AfterEach @BeforeEach process.
"Per-class" model has some additional benefits than the default "per-method" mode. Specifically, the use of "per-class" mode, you can declare @BeforeAll and @AfterAll on non-static methods and interfaces default method. Thus, "per-class" mode can be used in the methods @BeforeAll and @AfterAll @Nested test class.