这是我的测试运行文件。它在 tearDownClass() 中抛出异常。
公共类 testrunner 扩展 AbstractTestNGCucumberTests { private TestNGCucumberRunner testNGCucumberRunner;
WebDriver driver;
WebDriverManager webDriverManager;
@BeforeClass(alwaysRun = true)
public void setUpClass() {
if(testNGCucumberRunner == null){
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}
}
@Test(dataProvider = "scenarios")
public void feature(PickleEventWrapper pickleEvent, CucumberFeatureWrapper cucumberFeature) throws Throwable {
testNGCucumberRunner.runScenario(pickleEvent.getPickleEvent());
}
@Override
@DataProvider(parallel=true)
public Object[][] scenarios() {
return testNGCucumberRunner.provideScenarios();
}
@AfterClass(alwaysRun = true)
public void tearDownClass() {
testNGCucumberRunner.finish();
}
}
从控制台:
FAILURE! - in runner.testrunner
runScenario(runner.testrunner) Time elapsed: 0.01 sec <<< FAILURE!
java.lang.NullPointerException
runScenario(runner.testrunner) Time elapsed: 0.011 sec <<< FAILURE!
java.lang.NullPointerException
tearDownClass(runner.testrunner) Time elapsed: 56.248 sec <<< FAILURE!
java.lang.RuntimeException: java.io.IOException: Stream closed
at runner.testrunner.tearDownClass(testrunner.java:82)
Caused by: java.io.IOException: Stream closed
at runner.testrunner.tearDownClass(testrunner.java:82)
Results :
Failed tests:
runner.testrunner.runScenario(runner.testrunner)
Run 1: testrunner>AbstractTestNGCucumberTests.runScenario:24 » NullPointer
Run 2: testrunner>AbstractTestNGCucumberTests.runScenario:24 » NullPointer
testrunner.tearDownClass:82 » Runtime java.io.IOException: Stream closed