Home | History | Annotate | Download | only in test
      1 package test;
      2 
      3 import org.testng.Assert;
      4 import org.testng.IReporter;
      5 import org.testng.ISuite;
      6 import org.testng.ISuiteResult;
      7 import org.testng.ITestContext;
      8 import org.testng.TestNG;
      9 import org.testng.annotations.Test;
     10 import org.testng.xml.XmlSuite;
     11 
     12 import java.util.List;
     13 
     14 public class CountTest extends SimpleBaseTest {
     15 
     16   @Test(description = "Make sure that skipped methods are accurately counted")
     17   public void skippedMethodsShouldBeCounted() {
     18     TestNG tng = create(CountSampleTest.class);
     19 
     20     IReporter r = new IReporter() {
     21       @Override
     22       public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites,
     23           String outputDirectory) {
     24         for (ISuite s : suites) {
     25           for (ISuiteResult sr : s.getResults().values()) {
     26             ITestContext ctx = sr.getTestContext();
     27             Assert.assertEquals(2, ctx.getSkippedTests().size());
     28           }
     29         }
     30       }
     31     };
     32 
     33     tng.addListener(r);
     34     tng.run();
     35   }
     36 }
     37