From 3fa88c2b56b1a9c2c4f36ecc665fded0d4d91f80 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 14 Jul 2016 15:43:18 +0200 Subject: [PATCH] Document suppressed exception support in TestContextManager Issue: SPR-14459 --- .../test/context/TestContextManager.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java index 4aa1c4ec858..264b94eb42c 100644 --- a/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java +++ b/spring-test/src/main/java/org/springframework/test/context/TestContextManager.java @@ -335,9 +335,11 @@ public class TestContextManager { * {@code testInstance}, {@code testMethod}, and {@code exception}. *

Each registered {@link TestExecutionListener} will be given a chance * to perform its post-processing. If a listener throws an exception, the - * remaining registered listeners will still be called, but the first - * exception thrown will be tracked and rethrown after all listeners have - * executed. Note that registered listeners will be executed in the opposite + * remaining registered listeners will still be called. After all listeners + * have executed, the first caught exception will be rethrown with any + * subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in + * the first exception. + *

Note that registered listeners will be executed in the opposite * order in which they were registered. * @param testInstance the current test instance (never {@code null}) * @param testMethod the test method which has just been executed on the @@ -351,6 +353,7 @@ public class TestContextManager { * @see #afterTestMethod * @see #beforeTestExecution * @see #getTestExecutionListeners() + * @see Throwable#addSuppressed(Throwable) */ public void afterTestExecution(Object testInstance, Method testMethod, Throwable exception) throws Exception { String callbackName = "afterTestExecution"; @@ -394,10 +397,11 @@ public class TestContextManager { * {@code testInstance}, {@code testMethod}, and {@code exception}. *

Each registered {@link TestExecutionListener} will be given a chance * to perform its post-processing. If a listener throws an exception, the - * remaining registered listeners will still be called, but the first - * exception thrown will be tracked and rethrown after all listeners have - * executed. Note that registered listeners will be executed in the opposite - * order in which they were registered. + * remaining registered listeners will still be called. After all listeners + * have executed, the first caught exception will be rethrown with any + * subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in + * the first exception. + *

Note that registered listeners will be executed in the opposite * @param testInstance the current test instance (never {@code null}) * @param testMethod the test method which has just been executed on the * test instance @@ -409,6 +413,7 @@ public class TestContextManager { * @see #beforeTestExecution * @see #afterTestExecution * @see #getTestExecutionListeners() + * @see Throwable#addSuppressed(Throwable) */ public void afterTestMethod(Object testInstance, Method testMethod, Throwable exception) throws Exception { String callbackName = "afterTestMethod"; @@ -441,15 +446,17 @@ public class TestContextManager { * tests within the class. Should be called after any framework-specific * after class methods (e.g., methods annotated with JUnit 4's * {@link org.junit.AfterClass @AfterClass}). - *

Each registered {@link TestExecutionListener} will be given a chance to - * post-process the test class. If a listener throws an exception, the - * remaining registered listeners will still be called, but the first - * exception thrown will be tracked and rethrown after all listeners have - * executed. Note that registered listeners will be executed in the opposite - * order in which they were registered. + *

Each registered {@link TestExecutionListener} will be given a chance + * to perform its post-processing. If a listener throws an exception, the + * remaining registered listeners will still be called. After all listeners + * have executed, the first caught exception will be rethrown with any + * subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in + * the first exception. + *

Note that registered listeners will be executed in the opposite * @throws Exception if a registered TestExecutionListener throws an exception * @since 3.0 * @see #getTestExecutionListeners() + * @see Throwable#addSuppressed(Throwable) */ public void afterTestClass() throws Exception { Class testClass = getTestContext().getTestClass();