Skip to content

Commit e97febe

Browse files
committed
Fix null pointer exception in TestNG when invalid options are used
Using invalid options through `cucumber.option` would cause the creation of `testNGCucumberRunner` to fail with an exception. However this exception does not terminate TestNGs execution. This caused additional exceptions in the data provider and tear down methods. The additional exceptions were mistaken for the root cause, creating some confusion.
1 parent f7000b2 commit e97febe

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
77
### Deprecated
88
### Removed
99
### Fixed
10+
* [TestNG] Fix null pointer exception when invalid options are used ([#1282](https://github.com/cucumber/cucumber-jvm/pull/1282), M.P. Korstanje)
11+
1012

1113
## [2.1.0](https://github.com/cucumber/cucumber-jvm/compare/v2.0.1...v2.1.0)
1214

testng/src/main/java/cucumber/api/testng/AbstractTestNGCucumberTests.java

+6
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ public void runScenario(PickleEventWrapper pickleWrapper, CucumberFeatureWrapper
2929
*/
3030
@DataProvider
3131
public Object[][] scenarios() {
32+
if (testNGCucumberRunner == null) {
33+
return new Object[0][0];
34+
}
3235
return testNGCucumberRunner.provideScenarios();
3336
}
3437

3538
@AfterClass(alwaysRun = true)
3639
public void tearDownClass() throws Exception {
40+
if (testNGCucumberRunner == null) {
41+
return;
42+
}
3743
testNGCucumberRunner.finish();
3844
}
3945
}

0 commit comments

Comments
 (0)