package test.dataprovider;

import org.testng.Assert;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.TestNGException;
import org.testng.annotations.Test;


public class FailingDataProviderTest {
  @Test(description = "TESTNG-142: Exceptions in DataProvider are not reported as failed test")
  public void failingDataProvider() {
    TestNG testng= new TestNG(false);
    testng.setTestClasses(new Class[] {FailingDataProvider.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    testng.addListener(tla);
    testng.setVerbose(0);
    testng.run();
    Assert.assertEquals(tla.getSkippedTests().size(), 1, "Test method should be marked as skipped");
  }

  @Test(expectedExceptions = TestNGException.class,
      description = "TESTNG-447: abort when two data providers have the same name")
  public void duplicateDataProviders() {
    TestNG testng= new TestNG(false);
    testng.setTestClasses(new Class[] {DuplicateDataProviderSampleTest.class});
    testng.run();
  }
}

@@ -192,16 +192,45 @@
 est;%0D%0A%0D%0A
+import test.SimpleBaseTest;%0D%0A
 %0D%0Apublic
@@ -264,251 +264,123 @@
 est 
-%7B%0D%0A  @Test(description = %22TESTNG-142: Exceptions in DataProvider are not reported as failed test%22)
+extends SimpleBaseTest %7B
 %0D%0A  p
-ublic void failingDataProvider() %7B%0D%0A    TestNG testng= new TestNG(false);%0D%0A    testng.setTestClasses(new Class%5B%5D %7BFailingDataProvider.class%7D
+rivate void shouldSkipOne(Class cls, String message) %7B%0D%0A    TestNG testng = create(cls
 );%0D%0A
@@ -471,35 +471,8 @@
 );%0D%0A
-    testng.setVerbose(0);%0D%0A
     
@@ -547,119 +547,267 @@
  1, 
-%22Test method should be marked as skipped%22);%0D%0A  %7D%0D%0A%0D%0A  @Test(expectedExceptions = TestNGException.class,
+message);%0D%0A  %7D%0D%0A%0D%0A  @Test(description = %22TESTNG-142: Exceptions in DataProvider are not reported as failed test%22)%0D%0A  public void failingDataProvider() %7B%0D%0A    shouldSkipOne(FailingDataProvider.class, %22Test method should be marked as skipped%22);
 %0D%0A  
-    
+%7D%0D%0A%0D%0A  @Test(
 desc
@@ -829,17 +829,17 @@
 NG-447: 
-a
+A
 bort whe
@@ -931,82 +931,22 @@
     
-TestNG testng= new TestNG(false);%0D%0A    testng.setTestClasses(new Class%5B%5D %7B
+shouldSkipOne(
 Dupl
@@ -982,28 +982,12 @@
 lass
-%7D);%0D%0A    testng.run(
+, %22%22
 );%0D%0A

Test refactoring.