shank087 shank087 - 11 months ago 59
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.