|
31 | 31 | import org.junit.platform.engine.support.descriptor.ClassSource;
|
32 | 32 | import org.junit.platform.engine.support.descriptor.MethodSource;
|
33 | 33 | import org.junit.platform.launcher.LauncherDiscoveryRequest;
|
34 |
| -import org.junit.platform.launcher.TestIdentifier; |
35 | 34 | import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
|
36 | 35 | import org.junit.platform.launcher.core.LauncherFactory;
|
37 | 36 | import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
|
@@ -196,45 +195,28 @@ private static void runTestsInAotMode(long expectedNumTests, List<Class<?>> test
|
196 | 195 | private static void printFailingTestClasses(TestExecutionSummary summary) {
|
197 | 196 | System.err.println("Failing Test Classes:");
|
198 | 197 | summary.getFailures().stream()
|
199 |
| - .map(Failure::getTestIdentifier) |
200 |
| - .map(TestIdentifier::getSource) |
| 198 | + .map(failure -> failure.getTestIdentifier().getSource()) |
201 | 199 | .flatMap(Optional::stream)
|
202 |
| - .map(TestSource.class::cast) |
203 |
| - .map(source -> { |
204 |
| - if (source instanceof ClassSource classSource) { |
205 |
| - return getJavaClass(classSource); |
206 |
| - } |
207 |
| - else if (source instanceof MethodSource methodSource) { |
208 |
| - return getJavaClass(methodSource); |
209 |
| - } |
210 |
| - return Optional.<Class<?>> empty(); |
211 |
| - }) |
212 |
| - .flatMap(Optional::stream) |
213 |
| - .map(Class::getName) |
| 200 | + .map(AotIntegrationTests::getJavaClassName) |
214 | 201 | .distinct()
|
215 | 202 | .sorted()
|
216 | 203 | .forEach(System.err::println);
|
217 | 204 | System.err.println();
|
218 | 205 | }
|
219 | 206 |
|
220 |
| - private static Optional<Class<?>> getJavaClass(ClassSource classSource) { |
221 |
| - try { |
222 |
| - return Optional.of(classSource.getJavaClass()); |
223 |
| - } |
224 |
| - catch (Exception ex) { |
225 |
| - // ignore exception |
226 |
| - return Optional.empty(); |
227 |
| - } |
228 |
| - } |
229 |
| - |
230 |
| - private static Optional<Class<?>> getJavaClass(MethodSource methodSource) { |
| 207 | + private static String getJavaClassName(TestSource source) { |
231 | 208 | try {
|
232 |
| - return Optional.of(methodSource.getJavaClass()); |
| 209 | + if (source instanceof ClassSource classSource) { |
| 210 | + return classSource.getJavaClass().getName(); |
| 211 | + } |
| 212 | + else if (source instanceof MethodSource methodSource) { |
| 213 | + return methodSource.getJavaClass().getName(); |
| 214 | + } |
233 | 215 | }
|
234 | 216 | catch (Exception ex) {
|
235 |
| - // ignore exception |
236 |
| - return Optional.empty(); |
| 217 | + // ignore |
237 | 218 | }
|
| 219 | + return "<unknown>"; |
238 | 220 | }
|
239 | 221 |
|
240 | 222 | private static TestClassScanner createTestClassScanner() {
|
|
0 commit comments