Skip to content

Commit 41098d5

Browse files
committed
Print test summary for AotIntegrationTests.endToEndTestsForEntireSpringTestModule()
Current results for the spring-test module: Test run finished after 6785 ms [ 403 containers found ] [ 6 containers skipped ] [ 397 containers started ] [ 0 containers aborted ] [ 381 containers successful ] [ 16 containers failed ] [ 757 tests found ] [ 41 tests skipped ] [ 703 tests started ] [ 9 tests aborted ] [ 599 tests successful ] [ 95 tests failed ] Failing Test Classes: org.springframework.test.context.testng.transaction.ejb.RollbackForRequiresNewEjbTxDaoTestNGTests org.springframework.test.context.testng.transaction.ejb.CommitForRequiredEjbTxDaoTestNGTests org.springframework.test.context.testng.transaction.ejb.RollbackForRequiredEjbTxDaoTestNGTests org.springframework.test.context.testng.transaction.ejb.CommitForRequiresNewEjbTxDaoTestNGTests org.springframework.test.context.env.ExplicitPropertiesFileTestPropertySourceTests$ClasspathTests$PlaceholderAndClasspathPrefixTests org.springframework.test.context.env.ExplicitPropertiesFileTestPropertySourceTests$ClasspathTests$PlaceholderTests org.springframework.test.context.env.ExplicitPropertiesFileTestPropertySourceTests$FileSystemTests$CustomPlaceholderTests org.springframework.test.context.env.ExplicitPropertiesFileTestPropertySourceTests$FileSystemTests$PlaceholdersFollowedByRelativePathsTests org.springframework.test.context.env.ExplicitPropertiesFileTestPropertySourceTests$FileSystemTests$UserDirAndCustomPlaceholdersTests org.springframework.test.web.servlet.samples.client.context.WebAppResourceTests org.springframework.test.web.servlet.samples.client.context.XmlConfigTests org.springframework.test.web.servlet.samples.context.WebAppResourceTests org.springframework.test.web.servlet.samples.context.XmlConfigTests org.springframework.test.context.junit4.ParameterizedDependencyInjectionTests org.springframework.test.context.junit4.nested.NestedTestsWithSpringRulesTests$NestedTestCase org.springframework.test.context.junit4.spr9799.Spr9799XmlConfigTests See gh-29122
1 parent 3ad79e9 commit 41098d5

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

spring-test/src/test/java/org/springframework/test/context/aot/AotIntegrationTests.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@
1616

1717
package org.springframework.test.context.aot;
1818

19+
import java.io.PrintWriter;
1920
import java.nio.file.Path;
2021
import java.nio.file.Paths;
2122
import java.util.List;
23+
import java.util.Optional;
2224
import java.util.Set;
2325
import java.util.stream.Stream;
2426

2527
import org.junit.jupiter.api.Disabled;
2628
import org.junit.jupiter.api.Test;
2729
import org.junit.platform.engine.discovery.ClassNameFilter;
30+
import org.junit.platform.engine.support.descriptor.ClassSource;
2831
import org.junit.platform.launcher.LauncherDiscoveryRequest;
32+
import org.junit.platform.launcher.TestIdentifier;
2933
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
3034
import org.junit.platform.launcher.core.LauncherFactory;
3135
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
@@ -123,7 +127,8 @@ void endToEndTestsForEntireSpringTestModule() {
123127
// AOT BUILD-TIME: CLASSPATH SCANNING
124128
//
125129
// 1) You can limit execution to a particular set of test classes.
126-
// List<Class<?>> testClasses = List.of(DirtiesContextTransactionalTestNGSpringContextTests.class);
130+
// List<Class<?>> testClasses = List.of(org.springframework.test.web.servlet.samples.spr.EncodedUriTests.class,
131+
// org.springframework.test.web.servlet.samples.spr.HttpOptionsTests.class);
127132
//
128133
// 2) Or you can use the TestClassScanner to find test classes.
129134
List<Class<?>> testClasses = createTestClassScanner()
@@ -138,7 +143,7 @@ void endToEndTestsForEntireSpringTestModule() {
138143

139144
// AOT BUILD-TIME: PROCESSING
140145
InMemoryGeneratedFiles generatedFiles = new InMemoryGeneratedFiles();
141-
// Set failOnError flag to false to allow processing to continue.
146+
// Optionally set failOnError flag to true to halt processing at the first failure.
142147
TestContextAotGenerator generator = new TestContextAotGenerator(generatedFiles, new RuntimeHints(), false);
143148
generator.processAheadOfTime(testClasses.stream());
144149

@@ -166,7 +171,22 @@ private static void runTestsInAotMode(long expectedNumTests, List<Class<?>> test
166171
SummaryGeneratingListener listener = new SummaryGeneratingListener();
167172
LauncherFactory.create().execute(request, listener);
168173
TestExecutionSummary summary = listener.getSummary();
174+
if (expectedNumTests < 0) {
175+
summary.printTo(new PrintWriter(System.err));
176+
}
169177
if (summary.getTotalFailureCount() > 0) {
178+
System.err.println("Failing Test Classes:");
179+
summary.getFailures().stream()
180+
.map(Failure::getTestIdentifier)
181+
.map(TestIdentifier::getSource)
182+
.flatMap(Optional::stream)
183+
.filter(ClassSource.class::isInstance)
184+
.map(ClassSource.class::cast)
185+
.map(AotIntegrationTests::getJavaClass)
186+
.flatMap(Optional::stream)
187+
.map(Class::getName)
188+
.forEach(System.err::println);
189+
System.err.println();
170190
List<Throwable> exceptions = summary.getFailures().stream().map(Failure::getException).toList();
171191
throw new MultipleFailuresError("Test execution failures", exceptions);
172192
}
@@ -179,6 +199,16 @@ private static void runTestsInAotMode(long expectedNumTests, List<Class<?>> test
179199
}
180200
}
181201

202+
private static Optional<Class<?>> getJavaClass(ClassSource classSource) {
203+
try {
204+
return Optional.of(classSource.getJavaClass());
205+
}
206+
catch (Exception ex) {
207+
// ignore exception
208+
return Optional.empty();
209+
}
210+
}
211+
182212
private static TestClassScanner createTestClassScanner() {
183213
String classpathRoot = System.getProperty(CLASSPATH_ROOT);
184214
assertThat(classpathRoot).as(CLASSPATH_ROOT).isNotNull();

0 commit comments

Comments
 (0)