shank087 shank087 - 1 year ago 76
Java Question

How to use "skipFailedInvocations" and "retryAnalyzer" using testNG?

How do we use

Annotation using testNG?

Request you to provide an example.

Answer Source

Example code:

Demo test class:

public class DemoClass{

@Test(skipFailedInvocations=true, retryAnalyzer=RetryAnalyzer.class)
public void test(){


Retry Analyzer class:

public class RetryAnalyzer implements IRetryAnalyzer  { 
private int count = 0; 
private int maxCount = 4; // set your count to re-run test

public boolean retry(ITestResult result) { 
        if(count < maxCount) {                     
                return true; 
        return false; 


If the value for skipFailedInvocations is set true and invocation count (here maxCount in the RetryAnalyzer class) is > 1, then all invocations after a failure will be marked as a SKIP instead of a FAIL.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download