testng icon indicating copy to clipboard operation
testng copied to clipboard

(InvocationCount or DataProvider) and RetryAnaylzer when used togther performs incorrect behaviour

Open shroffsagar opened this issue 10 years ago • 0 comments

Below are the steps to reproduce both the issue. For data provider issue, one needs to use a data provider with testinputs same as invocationCount.

@UseAsTestcaseName("Sanity-TC01010-test")
@MaxRetryCount(3)
@Test(groups="sanity test", invocationCount=2) // or a data provider with 2 inputs
public void test(){
    System.out.println("sample test : "+Thread.currentThread().hashCode());
    Assert.fail();
}

Above configures my RetryAnalyzer to max retry attempts to 3. And total invocationCount to 2 Below is the output

sample test : 2041228125
sample test : 2041228125
sample test : 2041228125
Completed retry
sample test : 2041228125
sample test : 2041228125
sample test : 2041228125
Completed retry
sample test : 2041228125
sample test : 2041228125
sample test : 2041228125
Completed retry

As noticed in the above output. Test is invoked more then twice.

The total invocation goes wrong only when a retry is invoked.

The current invocation depends on the total times the method is invoked. The count is cumulative with each new iteration.

Please review below examples. All the retry fails in below examples

@MaxRetryCount(4)
invocationCount=1 // or a data provider with 1 inputs
Total invocations made = 1

@MaxRetryCount(4)
invocationCount=2 // or a data provider with 2 inputs
Total invocations made = 3

@MaxRetryCount(4)
invocationCount=3 // or a data provider with 3 inputs
Total invocations made = 6

@MaxRetryCount(4)
invocationCount=4 // or a data provider with 4 inputs
Total invocations made = 10

shroffsagar avatar Nov 14 '15 19:11 shroffsagar