57
57
import org .junit .jupiter .api .extension .TestTemplateInvocationContextProvider ;
58
58
import org .junit .platform .commons .util .ReflectionUtils ;
59
59
import org .junit .platform .engine .test .event .ExecutionEventRecorder ;
60
- import org .junit .platform .runner .JUnitPlatform ;
61
- import org .junit .runner .RunWith ;
62
60
63
61
/**
64
62
* Integration tests for {@link TestInstance @TestInstance} lifecycle support.
65
63
*
66
64
* @since 5.0
67
65
*/
68
- @ RunWith (JUnitPlatform .class )
69
- public
70
-
71
66
class TestInstanceLifecycleTests extends AbstractJupiterTestEngineTests {
72
67
73
68
private static final Map <String , Object > instanceMap = new LinkedHashMap <>();
@@ -155,7 +150,15 @@ void instancePerMethod() {
155
150
156
151
@ Test
157
152
void instancePerClass () {
158
- Class <?> testClass = InstancePerClassTestCase .class ;
153
+ instancePerClass (InstancePerClassTestCase .class );
154
+ }
155
+
156
+ @ Test
157
+ void instancePerClassWithInheritedLifecycleMode () {
158
+ instancePerClass (SubInstancePerClassTestCase .class );
159
+ }
160
+
161
+ private void instancePerClass (Class <?> testClass ) {
159
162
int containers = 3 ;
160
163
int tests = 3 ;
161
164
int instances = 1 ;
@@ -475,8 +478,6 @@ private void performAssertions(Class<?> testClass, int containers, int tests, in
475
478
476
479
ExecutionEventRecorder eventRecorder = executeTestsForClass (testClass );
477
480
478
- // eventRecorder.eventStream().forEach(System.out::println);
479
-
480
481
// @formatter:off
481
482
assertAll (
482
483
() -> assertEquals (containers , eventRecorder .getContainerStartedCount (), "# containers started" ),
@@ -584,7 +585,7 @@ static void afterAllStatic(TestInfo testInfo) {
584
585
}
585
586
586
587
@ TestInstance (Lifecycle .PER_CLASS )
587
- private static class InstancePerClassTestCase extends InstancePerMethodTestCase {
588
+ static class InstancePerClassTestCase extends InstancePerMethodTestCase {
588
589
589
590
@ BeforeAll
590
591
void beforeAll (TestInfo testInfo ) {
@@ -600,6 +601,9 @@ void afterAll(TestInfo testInfo) {
600
601
601
602
}
602
603
604
+ private static class SubInstancePerClassTestCase extends InstancePerClassTestCase {
605
+ }
606
+
603
607
@ ExtendWith (InstanceTrackingExtension .class )
604
608
// The following is commented out b/c it's the default.
605
609
// @TestInstance(Lifecycle.PER_METHOD)
0 commit comments