Home | History | Annotate | Download | only in dataprovider
      1 package test.dataprovider;
      2 
      3 import org.testng.Assert;
      4 import org.testng.TestListenerAdapter;
      5 import org.testng.TestNG;
      6 import org.testng.annotations.Test;
      7 
      8 import test.SimpleBaseTest;
      9 
     10 public class FailingDataProviderTest extends SimpleBaseTest {
     11   private void shouldSkip(Class cls, String message, int expected) {
     12     TestNG testng = create(cls);
     13     TestListenerAdapter tla = new TestListenerAdapter();
     14     testng.addListener(tla);
     15     testng.run();
     16     Assert.assertEquals(tla.getSkippedTests().size(), expected, message);
     17   }
     18 
     19   @Test(description = "TESTNG-142: Exceptions in DataProvider are not reported as failed test")
     20   public void failingDataProvider() {
     21     shouldSkip(FailingDataProvider.class, "Test method should be marked as skipped", 1);
     22   }
     23 
     24   @Test(description = "TESTNG-447: Abort when two data providers have the same name")
     25   public void duplicateDataProviders() {
     26     shouldSkip(DuplicateDataProviderSampleTest.class, "", 1);
     27   }
     28 
     29   @Test
     30   public void failingDataProviderAndInvocationCount() throws Exception {
     31     shouldSkip(DataProviderWithError.class,
     32         "Test should be skipped even if invocation counter and success percentage set", 4);
     33   }
     34 }
     35