10
10
11
11
package org .junit .platform .suite .engine ;
12
12
13
+ import static java .util .Objects .requireNonNull ;
13
14
import static java .util .function .Predicate .isEqual ;
14
15
import static java .util .stream .Collectors .joining ;
15
16
import static org .junit .platform .commons .support .AnnotationSupport .findAnnotation ;
21
22
import java .util .function .BiFunction ;
22
23
import java .util .function .Predicate ;
23
24
25
+ import org .jspecify .annotations .Nullable ;
24
26
import org .junit .platform .commons .JUnitException ;
25
27
import org .junit .platform .commons .support .ReflectionSupport ;
26
28
import org .junit .platform .commons .util .Preconditions ;
@@ -71,7 +73,10 @@ final class SuiteTestDescriptor extends AbstractTestDescriptor {
71
73
private final Class <?> suiteClass ;
72
74
private final LifecycleMethods lifecycleMethods ;
73
75
76
+ @ Nullable
74
77
private LauncherDiscoveryResult launcherDiscoveryResult ;
78
+
79
+ @ Nullable
75
80
private SuiteLauncher launcher ;
76
81
77
82
SuiteTestDescriptor (UniqueId id , Class <?> suiteClass , ConfigurationParameters configurationParameters ,
@@ -174,6 +179,7 @@ private void executeBeforeSuiteMethods(ThrowableCollector throwableCollector) {
174
179
}
175
180
}
176
181
182
+ @ Nullable
177
183
private TestExecutionSummary executeTests (EngineExecutionListener parentEngineExecutionListener ,
178
184
NamespacedHierarchicalStore <Namespace > requestLevelStore , ThrowableCollector throwableCollector ) {
179
185
if (throwableCollector .isNotEmpty ()) {
@@ -183,9 +189,9 @@ private TestExecutionSummary executeTests(EngineExecutionListener parentEngineEx
183
189
// #2838: The discovery result from a suite may have been filtered by
184
190
// post discovery filters from the launcher. The discovery result should
185
191
// be pruned accordingly.
186
- LauncherDiscoveryResult discoveryResult = this .launcherDiscoveryResult .withRetainedEngines (
192
+ LauncherDiscoveryResult discoveryResult = requireNonNull ( this .launcherDiscoveryResult ) .withRetainedEngines (
187
193
getChildren ()::contains );
188
- return launcher .execute (discoveryResult , parentEngineExecutionListener , requestLevelStore );
194
+ return requireNonNull ( launcher ) .execute (discoveryResult , parentEngineExecutionListener , requestLevelStore );
189
195
}
190
196
191
197
private void executeAfterSuiteMethods (ThrowableCollector throwableCollector ) {
@@ -194,12 +200,13 @@ private void executeAfterSuiteMethods(ThrowableCollector throwableCollector) {
194
200
}
195
201
}
196
202
197
- private TestExecutionResult computeTestExecutionResult (TestExecutionSummary summary ,
203
+ private TestExecutionResult computeTestExecutionResult (@ Nullable TestExecutionSummary summary ,
198
204
ThrowableCollector throwableCollector ) {
199
- if (throwableCollector .isNotEmpty ()) {
200
- return TestExecutionResult .failed (throwableCollector .getThrowable ());
205
+ var throwable = throwableCollector .getThrowable ();
206
+ if (throwable != null ) {
207
+ return TestExecutionResult .failed (throwable );
201
208
}
202
- if (failIfNoTests && summary .getTestsFoundCount () == 0 ) {
209
+ if (failIfNoTests && requireNonNull ( summary ) .getTestsFoundCount () == 0 ) {
203
210
return TestExecutionResult .failed (new NoTestsDiscoveredException (suiteClass ));
204
211
}
205
212
return TestExecutionResult .successful ();
0 commit comments