Register runtime hints for skipped exceptions in the TestContext framework

Closes gh-31479
This commit is contained in:
Sam Brannen
2023-11-27 15:42:20 +01:00
parent 43700302c6
commit 246833329f
2 changed files with 27 additions and 0 deletions

View File

@@ -205,6 +205,7 @@ public class TestContextAotGenerator {
MultiValueMap<ClassName, Class<?>> initializerClassMappings = processAheadOfTime(mergedConfigMappings);
generateAotTestContextInitializerMappings(initializerClassMappings);
generateAotTestAttributeMappings();
registerSkippedExceptionTypes();
}
finally {
resetAotFactories();
@@ -422,6 +423,20 @@ public class TestContextAotGenerator {
this.runtimeHints.reflection().registerType(type, INVOKE_DECLARED_CONSTRUCTORS);
}
/**
* Register hints for skipped exception types loaded via reflection in
* {@link org.springframework.test.context.TestContextManager}.
* @since 6.1.2
*/
private void registerSkippedExceptionTypes() {
Stream.of(
"org.opentest4j.TestAbortedException",
"org.junit.AssumptionViolatedException",
"org.testng.SkipException")
.map(TypeReference::of)
.forEach(this.runtimeHints.reflection()::registerType);
}
private static boolean getFailOnErrorFlag() {
String failOnError = SpringProperties.getProperty(FAIL_ON_ERROR_PROPERTY_NAME);
if (StringUtils.hasText(failOnError)) {