Skip to content

Commit

Permalink
Introduce FailureDetector
Browse files Browse the repository at this point in the history
  • Loading branch information
baflQA committed Apr 3, 2019
1 parent 37aa3c2 commit 321fbcc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/test/java/testngparallel/FailureDetector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package testngparallel;

import org.testng.*;

public class FailureDetector implements IConfigurationListener, IDataProviderListener {
public static final String FAILURE = "failure";

@Override
public void onConfigurationFailure(ITestResult itr) {
itr.getTestContext().setAttribute(FAILURE, Boolean.TRUE.toString());
}

@Override
public void beforeDataProviderExecution(IDataProviderMethod dataProviderMethod, ITestNGMethod method, ITestContext iTestContext) {
if (iTestContext.getAttribute(FailureDetector.FAILURE) != null) {
throw new SkipException("Failure");
}
}
}

3 changes: 1 addition & 2 deletions src/test/java/testngparallel/MasterTestClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import testngparallel.listeners.TestReporter;

import java.lang.invoke.MethodHandles;

@Listeners({MasterTestClass.class, TestReporter.class})
@Listeners({MasterTestClass.class, TestReporter.class, FailureDetector.class})
public class MasterTestClass implements ITestListener, ISuiteListener {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Expand Down

0 comments on commit 321fbcc

Please sign in to comment.