Given my tested class with many nested classes inside:
class TestWithManyNested {
@RegisterExtension
static MyExtension extension = new MyExtension();
@Nested
class Nested1 {
@Test
void nested1() {
}
}
@Nested
class Nested2 {
@Test
void nested2() {
}
}
}
Here is my simple extension:
static class MyExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
@Override
public void beforeAll(ExtensionContext extensionContext) throws Exception {
System.out.println("beforeAll");
}
@Override
public void afterAll(ExtensionContext extensionContext) throws Exception {
System.out.println("afterAll");
}
}
How can I run my TestWithManyNested
with MyExtension
which just run beforeAll
only once for whole test