Skip to content

Commit 3fa88c2

Browse files
committed
Document suppressed exception support in TestContextManager
Issue: SPR-14459
1 parent e2b8a78 commit 3fa88c2

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

spring-test/src/main/java/org/springframework/test/context/TestContextManager.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ public void beforeTestExecution(Object testInstance, Method testMethod) throws E
335335
* {@code testInstance}, {@code testMethod}, and {@code exception}.
336336
* <p>Each registered {@link TestExecutionListener} will be given a chance
337337
* to perform its post-processing. If a listener throws an exception, the
338-
* remaining registered listeners will still be called, but the first
339-
* exception thrown will be tracked and rethrown after all listeners have
340-
* executed. Note that registered listeners will be executed in the opposite
338+
* remaining registered listeners will still be called. After all listeners
339+
* have executed, the first caught exception will be rethrown with any
340+
* subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in
341+
* the first exception.
342+
* <p>Note that registered listeners will be executed in the opposite
341343
* order in which they were registered.
342344
* @param testInstance the current test instance (never {@code null})
343345
* @param testMethod the test method which has just been executed on the
@@ -351,6 +353,7 @@ public void beforeTestExecution(Object testInstance, Method testMethod) throws E
351353
* @see #afterTestMethod
352354
* @see #beforeTestExecution
353355
* @see #getTestExecutionListeners()
356+
* @see Throwable#addSuppressed(Throwable)
354357
*/
355358
public void afterTestExecution(Object testInstance, Method testMethod, Throwable exception) throws Exception {
356359
String callbackName = "afterTestExecution";
@@ -394,10 +397,11 @@ public void afterTestExecution(Object testInstance, Method testMethod, Throwable
394397
* {@code testInstance}, {@code testMethod}, and {@code exception}.
395398
* <p>Each registered {@link TestExecutionListener} will be given a chance
396399
* to perform its post-processing. If a listener throws an exception, the
397-
* remaining registered listeners will still be called, but the first
398-
* exception thrown will be tracked and rethrown after all listeners have
399-
* executed. Note that registered listeners will be executed in the opposite
400-
* order in which they were registered.
400+
* remaining registered listeners will still be called. After all listeners
401+
* have executed, the first caught exception will be rethrown with any
402+
* subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in
403+
* the first exception.
404+
* <p>Note that registered listeners will be executed in the opposite
401405
* @param testInstance the current test instance (never {@code null})
402406
* @param testMethod the test method which has just been executed on the
403407
* test instance
@@ -409,6 +413,7 @@ public void afterTestExecution(Object testInstance, Method testMethod, Throwable
409413
* @see #beforeTestExecution
410414
* @see #afterTestExecution
411415
* @see #getTestExecutionListeners()
416+
* @see Throwable#addSuppressed(Throwable)
412417
*/
413418
public void afterTestMethod(Object testInstance, Method testMethod, Throwable exception) throws Exception {
414419
String callbackName = "afterTestMethod";
@@ -441,15 +446,17 @@ public void afterTestMethod(Object testInstance, Method testMethod, Throwable ex
441446
* tests within the class. Should be called after any framework-specific
442447
* <em>after class methods</em> (e.g., methods annotated with JUnit 4's
443448
* {@link org.junit.AfterClass @AfterClass}).
444-
* <p>Each registered {@link TestExecutionListener} will be given a chance to
445-
* post-process the test class. If a listener throws an exception, the
446-
* remaining registered listeners will still be called, but the first
447-
* exception thrown will be tracked and rethrown after all listeners have
448-
* executed. Note that registered listeners will be executed in the opposite
449-
* order in which they were registered.
449+
* <p>Each registered {@link TestExecutionListener} will be given a chance
450+
* to perform its post-processing. If a listener throws an exception, the
451+
* remaining registered listeners will still be called. After all listeners
452+
* have executed, the first caught exception will be rethrown with any
453+
* subsequent exceptions {@linkplain Throwable#addSuppressed suppressed} in
454+
* the first exception.
455+
* <p>Note that registered listeners will be executed in the opposite
450456
* @throws Exception if a registered TestExecutionListener throws an exception
451457
* @since 3.0
452458
* @see #getTestExecutionListeners()
459+
* @see Throwable#addSuppressed(Throwable)
453460
*/
454461
public void afterTestClass() throws Exception {
455462
Class<?> testClass = getTestContext().getTestClass();

0 commit comments

Comments
 (0)