Skip to content

Commit 620474d

Browse files
committed
Demo Test with @SpringJUnitConfig
1 parent 90b8a4c commit 620474d

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

demo/demo-maven-junit-platform-jupiter-boot34/src/test/java/com/github/seregamorph/testsmartcontext/MavenSmartDirtiesJupiterEngineTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.github.seregamorph.testsmartcontext.demo.ExtendWithTest;
1111
import com.github.seregamorph.testsmartcontext.demo.Integration1Test;
12+
import com.github.seregamorph.testsmartcontext.demo.Integration2SpringJUnitConfigTest;
1213
import com.github.seregamorph.testsmartcontext.demo.Integration2Test;
1314
import com.github.seregamorph.testsmartcontext.demo.NoBaseClass1IntegrationTest;
1415
import com.github.seregamorph.testsmartcontext.demo.NoBaseClass2IntegrationTest;
@@ -46,20 +47,21 @@ public void testSuite() {
4647
.build())
4748
.containerEvents();
4849

49-
// 10 = 7 ITs + 2 UTs + 1 suite
50+
// 15 = 12 ITs + 2 UTs + 1 suite
5051
events.assertStatistics(stats -> stats
51-
.started(14)
52-
.succeeded(14)
53-
.finished(14)
52+
.started(15)
53+
.succeeded(15)
54+
.finished(15)
5455
.aborted(0)
5556
.failed(0));
5657

57-
assertEquals(8, SmartDirtiesTestsHolder.classOrderStateMapSize());
58+
assertEquals(9, SmartDirtiesTestsHolder.classOrderStateMapSize());
5859

5960
assertTrue(SmartDirtiesTestsHolder.isFirstClassPerConfig(Integration1Test.class));
6061
assertFalse(SmartDirtiesTestsHolder.isFirstClassPerConfig(Integration1Test.NestedTest.class));
6162
assertFalse(SmartDirtiesTestsHolder.isFirstClassPerConfig(Integration1Test.NestedTest.DeeplyNestedTest.class));
62-
assertTrue(SmartDirtiesTestsHolder.isFirstClassPerConfig(Integration2Test.class));
63+
assertTrue(SmartDirtiesTestsHolder.isFirstClassPerConfig(Integration2SpringJUnitConfigTest.class));
64+
assertFalse(SmartDirtiesTestsHolder.isFirstClassPerConfig(Integration2Test.class));
6365
assertFalse(SmartDirtiesTestsHolder.isFirstClassPerConfig(ExtendWithTest.class));
6466
assertFalse(SmartDirtiesTestsHolder.isFirstClassPerConfig(NoBaseClass1IntegrationTest.class));
6567
assertFalse(SmartDirtiesTestsHolder.isFirstClassPerConfig(NoBaseClass2IntegrationTest.class));
@@ -70,6 +72,7 @@ public void testSuite() {
7072
assertFalse(SmartDirtiesTestsHolder.isLastClassPerConfig(Integration1Test.NestedTest.DeeplyNestedTest.class));
7173
assertFalse(SmartDirtiesTestsHolder.isLastClassPerConfig(Integration1Test.NestedTest.class));
7274
assertTrue(SmartDirtiesTestsHolder.isLastClassPerConfig(Integration1Test.class));
75+
assertFalse(SmartDirtiesTestsHolder.isLastClassPerConfig(Integration2SpringJUnitConfigTest.class));
7376
assertTrue(SmartDirtiesTestsHolder.isLastClassPerConfig(Integration2Test.class));
7477
assertFalse(SmartDirtiesTestsHolder.isLastClassPerConfig(ExtendWithTest.class));
7578
assertFalse(SmartDirtiesTestsHolder.isLastClassPerConfig(NoBaseClass1IntegrationTest.class));
@@ -88,8 +91,8 @@ public void testSuite() {
8891
TestEventTracker.assertConsumedEvent("Creating context for com.github.seregamorph.testsmartcontext.demo.Integration1Test");
8992
TestEventTracker.assertConsumedEvent("Created context for com.github.seregamorph.testsmartcontext.demo.Integration1Test");
9093
TestEventTracker.assertConsumedEvent("Destroying context for com.github.seregamorph.testsmartcontext.demo.Integration1Test");
91-
TestEventTracker.assertConsumedEvent("Creating context for com.github.seregamorph.testsmartcontext.demo.Integration2Test");
92-
TestEventTracker.assertConsumedEvent("Created context for com.github.seregamorph.testsmartcontext.demo.Integration2Test");
94+
TestEventTracker.assertConsumedEvent("Creating context for com.github.seregamorph.testsmartcontext.demo.Integration2SpringJUnitConfigTest");
95+
TestEventTracker.assertConsumedEvent("Created context for com.github.seregamorph.testsmartcontext.demo.Integration2SpringJUnitConfigTest");
9396
TestEventTracker.assertConsumedEvent("Destroying context for com.github.seregamorph.testsmartcontext.demo.Integration2Test");
9497
TestEventTracker.assertConsumedEvent("Creating context for com.github.seregamorph.testsmartcontext.demo.SampleIntegrationTest");
9598
TestEventTracker.assertConsumedEvent("Created context for com.github.seregamorph.testsmartcontext.demo.SampleIntegrationTest");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.github.seregamorph.testsmartcontext.demo;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
5+
6+
@SpringJUnitConfig(classes = {
7+
Integration2Test.Configuration.class
8+
})
9+
public class Integration2SpringJUnitConfigTest {
10+
11+
@Test
12+
public void test() {
13+
System.out.println("Integration2SpringJUnitConfigTest.test");
14+
}
15+
16+
}

0 commit comments

Comments
 (0)