File tree Expand file tree Collapse file tree 5 files changed +67
-1
lines changed
main/java/org/testng/internal/invokers
test/java/test/dataprovider Expand file tree Collapse file tree 5 files changed +67
-1
lines changed Original file line number Diff line number Diff line change 1
1
Current
2
+ Fixed: GITHUB-2888: Skipped Tests with DataProvider appear as failed (Joaquin Moreira)
2
3
Fixed: GITHUB-2884: Discrepancies with DataProvider and Retry of failed tests (Krishnan Mahadevan)
3
4
Fixed: GITHUB-2879: Test listeners specified in parent testng.xml file are not included in testng-failed.xml file (Krishnan Mahadevan)
4
5
Fixed: GITHUB-2866: TestNG.xml doesn't honour Parallel value of a clone (Krishnan Mahadevan)
Original file line number Diff line number Diff line change @@ -922,7 +922,8 @@ public int invoke(int invCount) {
922
922
m_configuration .isPropagateDataProviderFailureAsTestFailure ()
923
923
|| bag .isBubbleUpFailures ();
924
924
925
- if (throwable instanceof TestNGException || bubbleUpFailures ) {
925
+ if (!(throwable instanceof SkipException )
926
+ && (throwable instanceof TestNGException || bubbleUpFailures )) {
926
927
tr .setStatus (ITestResult .FAILURE );
927
928
m_notifier .addFailedTest (arguments .getTestMethod (), tr );
928
929
} else {
Original file line number Diff line number Diff line change 46
46
import test .dataprovider .issue2819 .TestClassSample ;
47
47
import test .dataprovider .issue2819 .TestClassUsingDataProviderRetrySample ;
48
48
import test .dataprovider .issue2819 .TestClassWithMultipleRetryImplSample ;
49
+ import test .dataprovider .issue2888 .SkipDataProviderSample ;
49
50
50
51
public class DataProviderTest extends SimpleBaseTest {
51
52
@@ -513,6 +514,14 @@ public void ensureTestNGFailsDueToDataProviderFailure2() {
513
514
assertThat (testng .getStatus ()).isEqualTo (1 );
514
515
}
515
516
517
+ @ Test (description = "GITHUB-2888" )
518
+ public void ensureTestNGSkipExceptionWillSkipTestWithDataProvider () {
519
+ TestNG testng = create (SkipDataProviderSample .class );
520
+ testng .propagateDataProviderFailureAsTestFailure ();
521
+ testng .run ();
522
+ assertThat (testng .getStatus ()).isEqualTo (2 );
523
+ }
524
+
516
525
@ Test (description = "GITHUB-2255" )
517
526
public void ensureDataProviderValuesAreVisibleToConfigMethods () {
518
527
TestNG testNG = create (test .dataprovider .issue2255 .TestClassSample .class );
Original file line number Diff line number Diff line change
1
+ package test .dataprovider .issue2888 ;
2
+
3
+ import java .util .Arrays ;
4
+ import org .testng .IDataProviderListener ;
5
+ import org .testng .IDataProviderMethod ;
6
+ import org .testng .ITestContext ;
7
+ import org .testng .ITestListener ;
8
+ import org .testng .ITestNGMethod ;
9
+ import org .testng .ITestResult ;
10
+ import org .testng .SkipException ;
11
+
12
+ public class SkipDataProviderListener implements ITestListener , IDataProviderListener {
13
+ @ Override
14
+ public void onTestStart (ITestResult result ) {
15
+ skipIfSkipMe (result .getMethod ());
16
+ }
17
+
18
+ @ Override
19
+ public void onTestSkipped (ITestResult result ) {}
20
+
21
+ @ Override
22
+ public void beforeDataProviderExecution (
23
+ IDataProviderMethod dataProviderMethod , ITestNGMethod method , ITestContext iTestContext ) {
24
+ skipIfSkipMe (method );
25
+ }
26
+
27
+ private static void skipIfSkipMe (ITestNGMethod testNGMethod ) {
28
+ if (Arrays .asList (testNGMethod .getGroups ()).contains ("SkipMe" ))
29
+ throw new SkipException ("Test was skipped" );
30
+ }
31
+ }
Original file line number Diff line number Diff line change
1
+ package test .dataprovider .issue2888 ;
2
+
3
+ import org .testng .Assert ;
4
+ import org .testng .annotations .DataProvider ;
5
+ import org .testng .annotations .Listeners ;
6
+ import org .testng .annotations .Test ;
7
+
8
+ @ Listeners ({SkipDataProviderListener .class })
9
+ public class SkipDataProviderSample {
10
+ @ Test (groups = "SkipMe" )
11
+ public void testSkip () {
12
+ Assert .fail ("This test should not execute, it should be skipped" );
13
+ }
14
+
15
+ @ DataProvider (name = "dataProvider" )
16
+ private Object [][] dataProvider () {
17
+ return new Object [][] {new Object [] {"test1" }};
18
+ }
19
+
20
+ @ Test (dataProvider = "dataProvider" , groups = "SkipMe" )
21
+ public void testSkipWithDataProvider (String a ) {
22
+ Assert .fail ("This test should not execute, it should be skipped" );
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments