• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.retryAnalyzer;
2 
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertFalse;
5 import static org.testng.Assert.assertTrue;
6 
7 import java.util.List;
8 
9 import org.testng.ITestResult;
10 import org.testng.TestListenerAdapter;
11 import org.testng.TestNG;
12 import org.testng.annotations.Test;
13 
14 import test.SimpleBaseTest;
15 
16 public class RetryAnalyzerTest extends SimpleBaseTest {
17     @Test
testInvocationCounts()18     public void testInvocationCounts() {
19         TestNG tng = create(InvocationCountTest.class);
20         TestListenerAdapter tla = new TestListenerAdapter();
21         tng.addListener(tla);
22 
23         tng.run();
24 
25         assertFalse(tng.hasFailure());
26         assertFalse(tng.hasSkip());
27 
28         assertTrue(tla.getFailedTests().isEmpty());
29 
30         List<ITestResult> fsp = tla.getFailedButWithinSuccessPercentageTests();
31         assertEquals(fsp.size(), 1);
32         assertEquals(fsp.get(0).getName(), "failAfterThreeRetries");
33 
34         List<ITestResult> skipped = tla.getSkippedTests();
35         assertEquals(skipped.size(), InvocationCountTest.invocations.size() - fsp.size());
36     }
37 }
38