@@ -335,9 +335,11 @@ public void beforeTestExecution(Object testInstance, Method testMethod) throws E
335
335
* {@code testInstance}, {@code testMethod}, and {@code exception}.
336
336
* <p>Each registered {@link TestExecutionListener} will be given a chance
337
337
* 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
341
343
* order in which they were registered.
342
344
* @param testInstance the current test instance (never {@code null})
343
345
* @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
351
353
* @see #afterTestMethod
352
354
* @see #beforeTestExecution
353
355
* @see #getTestExecutionListeners()
356
+ * @see Throwable#addSuppressed(Throwable)
354
357
*/
355
358
public void afterTestExecution (Object testInstance , Method testMethod , Throwable exception ) throws Exception {
356
359
String callbackName = "afterTestExecution" ;
@@ -394,10 +397,11 @@ public void afterTestExecution(Object testInstance, Method testMethod, Throwable
394
397
* {@code testInstance}, {@code testMethod}, and {@code exception}.
395
398
* <p>Each registered {@link TestExecutionListener} will be given a chance
396
399
* 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
401
405
* @param testInstance the current test instance (never {@code null})
402
406
* @param testMethod the test method which has just been executed on the
403
407
* test instance
@@ -409,6 +413,7 @@ public void afterTestExecution(Object testInstance, Method testMethod, Throwable
409
413
* @see #beforeTestExecution
410
414
* @see #afterTestExecution
411
415
* @see #getTestExecutionListeners()
416
+ * @see Throwable#addSuppressed(Throwable)
412
417
*/
413
418
public void afterTestMethod (Object testInstance , Method testMethod , Throwable exception ) throws Exception {
414
419
String callbackName = "afterTestMethod" ;
@@ -441,15 +446,17 @@ public void afterTestMethod(Object testInstance, Method testMethod, Throwable ex
441
446
* tests within the class. Should be called after any framework-specific
442
447
* <em>after class methods</em> (e.g., methods annotated with JUnit 4's
443
448
* {@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
450
456
* @throws Exception if a registered TestExecutionListener throws an exception
451
457
* @since 3.0
452
458
* @see #getTestExecutionListeners()
459
+ * @see Throwable#addSuppressed(Throwable)
453
460
*/
454
461
public void afterTestClass () throws Exception {
455
462
Class <?> testClass = getTestContext ().getTestClass ();
0 commit comments