1717import org .testng .TestNGException ;
1818import org .testng .annotations .IListenersAnnotation ;
1919import org .testng .internal .annotations .IAnnotationFinder ;
20+ import org .testng .util .Invocable ;
2021
2122/** A helper class that internally houses some of the listener related actions support. */
2223public final class TestListenerHelper {
@@ -34,7 +35,7 @@ public static void runPreConfigurationListeners(
3435 List <IConfigurationListener > original = ListenerOrderDeterminer .order (listeners , comparator );
3536
3637 for (IConfigurationListener icl : original ) {
37- icl .beforeConfiguration (tr );
38+ Invocable . runQuietly (() -> icl .beforeConfiguration (tr ) );
3839 try {
3940 icl .beforeConfiguration (tr , tm );
4041 } catch (Exception e ) {
@@ -55,23 +56,23 @@ public static void runPostConfigurationListeners(
5556 for (IConfigurationListener icl : listenersreversed ) {
5657 switch (tr .getStatus ()) {
5758 case ITestResult .SKIP :
58- icl .onConfigurationSkip (tr );
59+ Invocable . runQuietly (() -> icl .onConfigurationSkip (tr ) );
5960 try {
6061 icl .onConfigurationSkip (tr , tm );
6162 } catch (Exception e ) {
6263 ignoreInternalGradleException (e );
6364 }
6465 break ;
6566 case ITestResult .FAILURE :
66- icl .onConfigurationFailure (tr );
67+ Invocable . runQuietly (() -> icl .onConfigurationFailure (tr ) );
6768 try {
6869 icl .onConfigurationFailure (tr , tm );
6970 } catch (Exception e ) {
7071 ignoreInternalGradleException (e );
7172 }
7273 break ;
7374 case ITestResult .SUCCESS :
74- icl .onConfigurationSuccess (tr );
75+ Invocable . runQuietly (() -> icl .onConfigurationSuccess (tr ) );
7576 try {
7677 icl .onConfigurationSuccess (tr , tm );
7778 } catch (Exception e ) {
@@ -103,23 +104,23 @@ public static void runTestListeners(ITestResult tr, List<ITestListener> listener
103104 for (ITestListener itl : listeners ) {
104105 switch (tr .getStatus ()) {
105106 case ITestResult .SKIP :
106- itl .onTestSkipped (tr );
107+ Invocable . runQuietly (() -> itl .onTestSkipped (tr ) );
107108 break ;
108109 case ITestResult .SUCCESS_PERCENTAGE_FAILURE :
109- itl .onTestFailedButWithinSuccessPercentage (tr );
110+ Invocable . runQuietly (() -> itl .onTestFailedButWithinSuccessPercentage (tr ) );
110111 break ;
111112 case ITestResult .FAILURE :
112113 if (ITestResult .wasFailureDueToTimeout (tr )) {
113- itl .onTestFailedWithTimeout (tr );
114+ Invocable . runQuietly (() -> itl .onTestFailedWithTimeout (tr ) );
114115 } else {
115- itl .onTestFailure (tr );
116+ Invocable . runQuietly (() -> itl .onTestFailure (tr ) );
116117 }
117118 break ;
118119 case ITestResult .SUCCESS :
119- itl .onTestSuccess (tr );
120+ Invocable . runQuietly (() -> itl .onTestSuccess (tr ) );
120121 break ;
121122 case ITestResult .STARTED :
122- itl .onTestStart (tr );
123+ Invocable . runQuietly (() -> itl .onTestStart (tr ) );
123124 break ;
124125 default :
125126 throw new AssertionError ("Unknown status: " + tr .getStatus ());
0 commit comments