Skip to content

Commit 44931dc

Browse files
committed
Include all failing test classes in AOT end-to-end test report
Prior to this commit, AotIntegrationTests only printed "failing test classes" for tests that failed at the class level. This commit updates the reporting logic to report test classes for failing test methods as well. Current results for the spring-test module: Test run finished after 6531 ms [ 403 containers found ] [ 27 containers skipped ] [ 376 containers started ] [ 0 containers aborted ] [ 366 containers successful ] [ 10 containers failed ] [ 757 tests found ] [ 61 tests skipped ] [ 689 tests started ] [ 9 tests aborted ] [ 585 tests successful ] [ 95 tests failed ] Failing Test Classes: org.springframework.test.context.configuration.interfaces.ContextHierarchyInterfaceTests org.springframework.test.context.configuration.interfaces.SqlConfigInterfaceTests org.springframework.test.context.expression.ExpressionUsageTests org.springframework.test.context.groovy.AbsolutePathGroovySpringContextTests org.springframework.test.context.groovy.GroovySpringContextTests org.springframework.test.context.groovy.RelativePathGroovySpringContextTests org.springframework.test.context.hierarchies.meta.MetaHierarchyLevelTwoTests org.springframework.test.context.hierarchies.standard.ClassHierarchyWithMergedConfigLevelOneTests org.springframework.test.context.hierarchies.standard.ClassHierarchyWithMergedConfigLevelTwoTests org.springframework.test.context.hierarchies.standard.ClassHierarchyWithOverriddenConfigLevelTwoTests org.springframework.test.context.hierarchies.standard.DirtiesContextWithContextHierarchyTests org.springframework.test.context.hierarchies.standard.SingleTestClassWithTwoLevelContextHierarchyAndMixedConfigTypesTests org.springframework.test.context.hierarchies.standard.SingleTestClassWithTwoLevelContextHierarchyTests org.springframework.test.context.hierarchies.standard.TestHierarchyLevelTwoWithBareContextConfigurationInSubclassTests org.springframework.test.context.hierarchies.standard.TestHierarchyLevelTwoWithBareContextConfigurationInSuperclassTests org.springframework.test.context.hierarchies.standard.TestHierarchyLevelTwoWithSingleLevelContextHierarchyAndMixedConfigTypesTests org.springframework.test.context.hierarchies.standard.TestHierarchyLevelTwoWithSingleLevelContextHierarchyTests org.springframework.test.context.hierarchies.web.ControllerIntegrationTests org.springframework.test.context.hierarchies.web.DispatcherWacRootWacEarTests org.springframework.test.context.hierarchies.web.RootWacEarTests org.springframework.test.context.jdbc.CustomScriptSyntaxSqlScriptsTests org.springframework.test.context.jdbc.GlobalCustomScriptSyntaxSqlScriptsTests org.springframework.test.context.jdbc.InferredDataSourceTransactionalSqlScriptsTests org.springframework.test.context.jdbc.InfrastructureProxyTransactionalSqlScriptsTests org.springframework.test.context.jdbc.MultipleDataSourcesAndTransactionManagersSqlScriptsTests org.springframework.test.context.jdbc.MultipleDataSourcesAndTransactionManagersTransactionalSqlScriptsTests org.springframework.test.context.jdbc.NonTransactionalSqlScriptsTests org.springframework.test.context.jdbc.RepeatableSqlAnnotationSqlScriptsChildTests org.springframework.test.context.jdbc.RepeatableSqlAnnotationSqlScriptsParentTests org.springframework.test.context.jdbc.TransactionalAfterTestMethodSqlScriptsTests org.springframework.test.context.jdbc.TransactionalInlinedStatementsSqlScriptsTests org.springframework.test.context.junit.jupiter.nested.ContextHierarchyNestedTests$NestedTestCaseWithInheritedConfigTests org.springframework.test.context.junit.jupiter.nested.ContextHierarchyNestedTests$NestedTestCaseWithInheritedConfigTests$DoubleNestedTestCaseWithOverriddenConfigTests org.springframework.test.context.junit.jupiter.nested.ContextHierarchyNestedTests$NestedTestCaseWithInheritedConfigTests$DoubleNestedTestCaseWithOverriddenConfigTests$TripleNestedWithInheritedConfigAndTestInterfaceTests org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests$ConfigOverriddenByDefaultTests org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests$InheritedAndExtendedConfigTests org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests$InheritedAndExtendedConfigTests$DoubleNestedWithOverriddenConfigTests org.springframework.test.context.junit.jupiter.nested.TestExecutionListenersNestedTests$InheritedAndExtendedConfigTests$DoubleNestedWithOverriddenConfigTests$TripleNestedWithInheritedConfigAndTestInterfaceTests org.springframework.test.context.junit.jupiter.orm.JpaEntityListenerTests org.springframework.test.context.junit4.AbsolutePathSpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.ClassPathResourceSpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.ConcreteTransactionalJUnit4SpringContextTests org.springframework.test.context.junit4.InheritedConfigSpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.MultipleResourcesSpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.ParameterizedDependencyInjectionTests org.springframework.test.context.junit4.RelativePathSpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.SpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.annotation.AnnotationConfigSpringJUnit4ClassRunnerAppCtxTests org.springframework.test.context.junit4.rules.TransactionalSqlScriptsSpringRuleTests org.springframework.test.context.junit4.spr9799.Spr9799XmlConfigTests org.springframework.test.context.testng.ConcreteTransactionalTestNGSpringContextTests org.springframework.test.context.testng.transaction.ejb.CommitForRequiredEjbTxDaoTestNGTests org.springframework.test.context.testng.transaction.ejb.CommitForRequiresNewEjbTxDaoTestNGTests org.springframework.test.context.testng.transaction.ejb.RollbackForRequiredEjbTxDaoTestNGTests org.springframework.test.context.testng.transaction.ejb.RollbackForRequiresNewEjbTxDaoTestNGTests org.springframework.test.context.transaction.ejb.CommitForRequiredEjbTxDaoTests org.springframework.test.context.transaction.ejb.CommitForRequiresNewEjbTxDaoTests org.springframework.test.context.transaction.ejb.RollbackForRequiredEjbTxDaoTests org.springframework.test.context.transaction.ejb.RollbackForRequiresNewEjbTxDaoTests org.springframework.test.web.servlet.samples.client.context.JavaConfigTests 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.JavaConfigTests org.springframework.test.web.servlet.samples.context.WebAppResourceTests org.springframework.test.web.servlet.samples.context.XmlConfigTests See gh-29122
1 parent 32b4f55 commit 44931dc

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

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

+37-12
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626

2727
import org.junit.jupiter.api.Disabled;
2828
import org.junit.jupiter.api.Test;
29+
import org.junit.platform.engine.TestSource;
2930
import org.junit.platform.engine.discovery.ClassNameFilter;
3031
import org.junit.platform.engine.support.descriptor.ClassSource;
32+
import org.junit.platform.engine.support.descriptor.MethodSource;
3133
import org.junit.platform.launcher.LauncherDiscoveryRequest;
3234
import org.junit.platform.launcher.TestIdentifier;
3335
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
@@ -176,18 +178,7 @@ private static void runTestsInAotMode(long expectedNumTests, List<Class<?>> test
176178
summary.printTo(new PrintWriter(System.err));
177179
}
178180
if (summary.getTotalFailureCount() > 0) {
179-
System.err.println("Failing Test Classes:");
180-
summary.getFailures().stream()
181-
.map(Failure::getTestIdentifier)
182-
.map(TestIdentifier::getSource)
183-
.flatMap(Optional::stream)
184-
.filter(ClassSource.class::isInstance)
185-
.map(ClassSource.class::cast)
186-
.map(AotIntegrationTests::getJavaClass)
187-
.flatMap(Optional::stream)
188-
.map(Class::getName)
189-
.forEach(System.err::println);
190-
System.err.println();
181+
printFailingTestClasses(summary);
191182
List<Throwable> exceptions = summary.getFailures().stream().map(Failure::getException).toList();
192183
throw new MultipleFailuresError("Test execution failures", exceptions);
193184
}
@@ -200,6 +191,30 @@ private static void runTestsInAotMode(long expectedNumTests, List<Class<?>> test
200191
}
201192
}
202193

194+
private static void printFailingTestClasses(TestExecutionSummary summary) {
195+
System.err.println("Failing Test Classes:");
196+
summary.getFailures().stream()
197+
.map(Failure::getTestIdentifier)
198+
.map(TestIdentifier::getSource)
199+
.flatMap(Optional::stream)
200+
.map(TestSource.class::cast)
201+
.map(source -> {
202+
if (source instanceof ClassSource classSource) {
203+
return getJavaClass(classSource);
204+
}
205+
else if (source instanceof MethodSource methodSource) {
206+
return getJavaClass(methodSource);
207+
}
208+
return Optional.<Class<?>> empty();
209+
})
210+
.flatMap(Optional::stream)
211+
.map(Class::getName)
212+
.distinct()
213+
.sorted()
214+
.forEach(System.err::println);
215+
System.err.println();
216+
}
217+
203218
private static Optional<Class<?>> getJavaClass(ClassSource classSource) {
204219
try {
205220
return Optional.of(classSource.getJavaClass());
@@ -210,6 +225,16 @@ private static Optional<Class<?>> getJavaClass(ClassSource classSource) {
210225
}
211226
}
212227

228+
private static Optional<Class<?>> getJavaClass(MethodSource methodSource) {
229+
try {
230+
return Optional.of(methodSource.getJavaClass());
231+
}
232+
catch (Exception ex) {
233+
// ignore exception
234+
return Optional.empty();
235+
}
236+
}
237+
213238
private static TestClassScanner createTestClassScanner() {
214239
String classpathRoot = System.getProperty(CLASSPATH_ROOT);
215240
assertThat(classpathRoot).as(CLASSPATH_ROOT).isNotNull();

0 commit comments

Comments
 (0)