10
10
11
11
package org .junit .jupiter .engine ;
12
12
13
+ import static org .assertj .core .api .Assertions .assertThat ;
13
14
import static org .junit .jupiter .api .Assertions .assertAll ;
14
15
import static org .junit .jupiter .api .Assertions .assertEquals ;
15
16
import static org .junit .platform .engine .discovery .DiscoverySelectors .selectClass ;
16
17
import static org .junit .platform .engine .discovery .DiscoverySelectors .selectMethod ;
17
18
import static org .junit .platform .engine .discovery .DiscoverySelectors .selectUniqueId ;
19
+ import static org .junit .platform .launcher .LauncherConstants .CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME ;
18
20
import static org .junit .platform .launcher .core .LauncherDiscoveryRequestBuilder .request ;
19
21
import static org .junit .platform .testkit .engine .EventConditions .finishedWithFailure ;
20
22
import static org .junit .platform .testkit .engine .TestExecutionResultConditions .message ;
21
23
24
+ import java .util .List ;
25
+
22
26
import org .junit .jupiter .api .AfterEach ;
23
27
import org .junit .jupiter .api .Assertions ;
24
28
import org .junit .jupiter .api .BeforeEach ;
27
31
import org .junit .jupiter .engine .NestedTestClassesTests .OuterClass .NestedClass ;
28
32
import org .junit .jupiter .engine .NestedTestClassesTests .OuterClass .NestedClass .RecursiveNestedClass ;
29
33
import org .junit .jupiter .engine .NestedTestClassesTests .OuterClass .NestedClass .RecursiveNestedSiblingClass ;
34
+ import org .junit .platform .engine .DiscoveryIssue .Severity ;
30
35
import org .junit .platform .engine .TestDescriptor ;
36
+ import org .junit .platform .engine .support .descriptor .ClassSource ;
31
37
import org .junit .platform .launcher .LauncherDiscoveryRequest ;
32
38
import org .junit .platform .testkit .engine .EngineExecutionResults ;
33
39
import org .junit .platform .testkit .engine .Events ;
@@ -95,7 +101,14 @@ void doublyNestedTestsAreExecuted() {
95
101
96
102
@ Test
97
103
void inheritedNestedTestsAreExecuted () {
98
- EngineExecutionResults executionResults = executeTestsForClass (TestCaseWithInheritedNested .class );
104
+ var discoveryIssues = discoverTestsForClass (TestCaseWithInheritedNested .class ).getDiscoveryIssues ();
105
+ assertThat (discoveryIssues ).hasSize (1 );
106
+ assertThat (discoveryIssues .getFirst ().source ()) //
107
+ .contains (ClassSource .from (InterfaceWithNestedClass .NestedInInterface .class ));
108
+
109
+ var executionResults = executeTests (request -> request //
110
+ .selectors (selectClass (TestCaseWithInheritedNested .class )) //
111
+ .configurationParameter (CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME , Severity .ERROR .name ()));
99
112
Events containers = executionResults .containerEvents ();
100
113
Events tests = executionResults .testEvents ();
101
114
@@ -109,7 +122,14 @@ void inheritedNestedTestsAreExecuted() {
109
122
110
123
@ Test
111
124
void extendedNestedTestsAreExecuted () {
112
- var executionResults = executeTestsForClass (TestCaseWithExtendedNested .class );
125
+ var discoveryIssues = discoverTestsForClass (TestCaseWithExtendedNested .class ).getDiscoveryIssues ();
126
+ assertThat (discoveryIssues ).hasSize (1 );
127
+ assertThat (discoveryIssues .getFirst ().source ()) //
128
+ .contains (ClassSource .from (InterfaceWithNestedClass .NestedInInterface .class ));
129
+
130
+ var executionResults = executeTests (request -> request //
131
+ .selectors (selectClass (TestCaseWithExtendedNested .class )) //
132
+ .configurationParameter (CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME , Severity .ERROR .name ()));
113
133
Events containers = executionResults .containerEvents ();
114
134
Events tests = executionResults .testEvents ();
115
135
@@ -123,10 +143,21 @@ void extendedNestedTestsAreExecuted() {
123
143
124
144
@ Test
125
145
void deeplyNestedInheritedMethodsAreExecutedWhenSelectedViaUniqueId () {
126
- var executionResults = executeTests (selectUniqueId (
127
- "[engine:junit-jupiter]/[class:org.junit.jupiter.engine.NestedTestClassesTests$TestCaseWithExtendedNested]/[nested-class:ConcreteInner1]/[nested-class:NestedInAbstractClass]/[nested-class:SecondLevelInherited]/[method:test()]" ),
146
+ var selectors = List .of ( //
147
+ selectUniqueId (
148
+ "[engine:junit-jupiter]/[class:org.junit.jupiter.engine.NestedTestClassesTests$TestCaseWithExtendedNested]/[nested-class:ConcreteInner1]/[nested-class:NestedInAbstractClass]/[nested-class:SecondLevelInherited]/[method:test()]" ),
128
149
selectUniqueId (
129
150
"[engine:junit-jupiter]/[class:org.junit.jupiter.engine.NestedTestClassesTests$TestCaseWithExtendedNested]/[nested-class:ConcreteInner2]/[nested-class:NestedInAbstractClass]/[nested-class:SecondLevelInherited]/[method:test()]" ));
151
+
152
+ var discoveryIssues = discoverTests (request -> request .selectors (selectors )).getDiscoveryIssues ();
153
+ assertThat (discoveryIssues ).hasSize (1 );
154
+ assertThat (discoveryIssues .getFirst ().source ()) //
155
+ .contains (ClassSource .from (InterfaceWithNestedClass .NestedInInterface .class ));
156
+
157
+ var executionResults = executeTests (request -> request //
158
+ .selectors (selectors ) //
159
+ .configurationParameter (CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME , Severity .ERROR .name ()));
160
+
130
161
Events containers = executionResults .containerEvents ();
131
162
Events tests = executionResults .testEvents ();
132
163
@@ -281,7 +312,7 @@ void failing() {
281
312
282
313
interface InterfaceWithNestedClass {
283
314
284
- @ SuppressWarnings ("JUnitMalformedDeclaration" )
315
+ @ SuppressWarnings ({ "JUnitMalformedDeclaration" , "NewClassNamingConvention" } )
285
316
@ Nested
286
317
class NestedInInterface {
287
318
@@ -333,7 +364,7 @@ class ConcreteInner2 extends AbstractSuperClass {
333
364
static class AbstractOuterClass {
334
365
}
335
366
336
- @ SuppressWarnings ("JUnitMalformedDeclaration" )
367
+ @ SuppressWarnings ({ "JUnitMalformedDeclaration" , "NewClassNamingConvention" } )
337
368
static class OuterClass extends AbstractOuterClass {
338
369
339
370
@ Test
0 commit comments