黄瓜测试跑步者失败

时间:2018-02-02 11:13:57

标签: java cucumber testng

以下是我的跑步者课程,

package runner;



import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

//@RunWith(Cucumber.class)
@CucumberOptions(features="resources/features",glue="step_def")

public class Runner extends AbstractTestNGCucumberTests {
 /* private TestNGCucumberRunner testNGCucumberRunner;

    @org.testng.annotations.BeforeClass(alwaysRun = true)
    public void setUpClass() throws Exception {
        testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
    }

    @org.testng.annotations.Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
    public void feature(CucumberFeatureWrapper cucumberFeature) {
        testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
    }

    @org.testng.annotations.DataProvider
    public Object[][] features() {
        return testNGCucumberRunner.provideFeatures();
    }

    @org.testng.annotations.AfterClass(alwaysRun = true)
    public void tearDownClass() throws Exception {
        testNGCucumberRunner.finish();
    }*/
}

每当我尝试将其作为TestNG测试运行时,我都会收到以下错误

  

[RemoteTestNG]检测到TestNG版本6.13.1 [实用程序] [错误] [错误]   java.lang.NullPointerException at   cucumber.api.testng.AbstractTestNGCucumberTests.features(AbstractTestNGCucumberTests.java:29)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)     在   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)     在   org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45)     在   org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131)     在   org.testng.internal.Parameters.handleParameters(Parameters.java:706)     在   org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:49)     在   org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:37)     在org.testng.internal.Invoker.invokeTestMethods(Invoker.java:914)     在   org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)     在   org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)     在org.testng.TestRunner.privateRun(TestRunner.java:648)at   org.testng.TestRunner.run(TestRunner.java:505)at   org.testng.SuiteRunner.runTest(SuiteRunner.java:455)at   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)at at   org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)at at   org.testng.SuiteRunner.run(SuiteRunner.java:364)at   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)at   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)at   org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)at at   org.testng.TestNG.runSuitesLocally(TestNG.java:1116)at at   org.testng.TestNG.runSuites(TestNG.java:1028)at   org.testng.TestNG.run(TestNG.java:996)at   org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)     在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)     在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

     

FAILED CONFIGURATION:@BeforeClass setUpClass   java.lang.NoSuchMethodError:   cucumber.runtime.RuntimeOptions.reporter(Ljava /郎/类加载器;)Lgherkin /格式化器/记者;     在   cucumber.api.testng.TestNGCucumberRunner。(TestNGCucumberRunner.java:41)     在   cucumber.api.testng.AbstractTestNGCucumberTests.setUpClass(AbstractTestNGCucumberTests.java:16)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)     在   org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)     在   org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)     在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)     在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)     在   org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:163)     在   org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)     在org.testng.TestRunner.privateRun(TestRunner.java:648)at   org.testng.TestRunner.run(TestRunner.java:505)at   org.testng.SuiteRunner.runTest(SuiteRunner.java:455)at   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)at at   org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)at at   org.testng.SuiteRunner.run(SuiteRunner.java:364)at   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)at   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)at   org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)at at   org.testng.TestNG.runSuitesLocally(TestNG.java:1116)at at   org.testng.TestNG.runSuites(TestNG.java:1028)at   org.testng.TestNG.run(TestNG.java:996)at   org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)     在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)     在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

     

FAILED CONFIGURATION:@AfterClass tearDownClass   java.lang.NullPointerException at   cucumber.api.testng.AbstractTestNGCucumberTests.tearDownClass(AbstractTestNGCucumberTests.java:34)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)     在   org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)     在   org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)     在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)     在org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)     在   org.testng.internal.TestMethodWorker.invokeAfterClassMethods(TestMethodWorker.java:208)     在   org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)     在org.testng.TestRunner.privateRun(TestRunner.java:648)at   org.testng.TestRunner.run(TestRunner.java:505)at   org.testng.SuiteRunner.runTest(SuiteRunner.java:455)at   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)at at   org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)at at   org.testng.SuiteRunner.run(SuiteRunner.java:364)at   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)at   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)at   org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)at at   org.testng.TestNG.runSuitesLocally(TestNG.java:1116)at at   org.testng.TestNG.runSuites(TestNG.java:1028)at   org.testng.TestNG.run(TestNG.java:996)at   org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)     在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)     在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

     

SKIPPED:功能            运行Cucumber功能java.lang.RuntimeException:java.lang.NullPointerException at   org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:49)     在   org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131)     在   org.testng.internal.Parameters.handleParameters(Parameters.java:706)     在   org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:49)     在   org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:37)     在org.testng.internal.Invoker.invokeTestMethods(Invoker.java:914)     在   org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)     在   org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)     在org.testng.TestRunner.privateRun(TestRunner.java:648)at   org.testng.TestRunner.run(TestRunner.java:505)at   org.testng.SuiteRunner.runTest(SuiteRunner.java:455)at   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)at at   org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)at at   org.testng.SuiteRunner.run(SuiteRunner.java:364)at   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)at   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)at   org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)at at   org.testng.TestNG.runSuitesLocally(TestNG.java:1116)at at   org.testng.TestNG.runSuites(TestNG.java:1028)at   org.testng.TestNG.run(TestNG.java:996)at   org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)     在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)     在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)引起   by:java.lang.NullPointerException at   cucumber.api.testng.AbstractTestNGCucumberTests.features(AbstractTestNGCucumberTests.java:29)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)     在   org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74)     在   org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:45)     ......还有22个

     

===============================================       默认测试       测试运行:1,失败:0,跳过:1

     

配置失败:2,跳过:0

     

===============================================默认套件总测试运行:1,失败:0,跳过:1配置失败:2,跳过:

     

0

我不确定我在这里失踪了什么。

1 个答案:

答案 0 :(得分:1)

功能文件的路径应从源文件夹开始。尝试一次。 它应该看起来像:-

features =“ src \\ bbd_feature”