• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package test.invocationcount;
2 
3 import org.testng.Assert;
4 import org.testng.TestListenerAdapter;
5 import org.testng.TestNG;
6 import org.testng.annotations.Test;
7 
8 public class FailedInvocationCountTest {
9 
runTest(boolean skip, int passed, int failed, int skipped)10   private void runTest(boolean skip,
11     int passed, int failed, int skipped)
12   {
13     TestNG testng = new TestNG();
14     testng.setVerbose(0);
15     testng.setSkipFailedInvocationCounts(skip);
16     testng.setTestClasses(new Class[] { FailedInvocationCount.class });
17     TestListenerAdapter tla = new TestListenerAdapter();
18     testng.addListener(tla);
19     testng.run();
20 
21     Assert.assertEquals(tla.getPassedTests().size(), passed);
22     Assert.assertEquals(tla.getFailedTests().size(), failed);
23     Assert.assertEquals(tla.getSkippedTests().size(), skipped);
24   }
25 
26   @Test
verifyGloballyShouldStop()27   public void verifyGloballyShouldStop() {
28     runTest(true, 4, 1, 5);
29   }
30 
31   @Test
verifyGloballyShouldNotStop()32   public void verifyGloballyShouldNotStop() {
33     runTest(false, 4, 6, 0);
34   }
35 
36   @Test
verifyAttributeShouldStop()37   public void verifyAttributeShouldStop() {
38     TestNG testng = new TestNG();
39     testng.setVerbose(0);
40     testng.setTestClasses(new Class[] { FailedInvocationCount2.class });
41     TestListenerAdapter tla = new TestListenerAdapter();
42     testng.addListener(tla);
43     testng.run();
44 
45     Assert.assertEquals(tla.getPassedTests().size(), 8);
46     Assert.assertEquals(tla.getFailedTests().size(), 7);
47     Assert.assertEquals(tla.getSkippedTests().size(), 5);
48 
49   }
50 }
51