如何从黄瓜项目中的多个功能文件运行功能文件

时间:2018-07-24 15:08:48

标签: java selenium automation cucumber bdd

Project structure我已经有了运行我的要素文件的运行器类,那时我只有一个功能文件,而该运行器类是:

@RunWith(Cucumber.class)
@CucumberOptions(features="Features",
                 tags = {"@E2E"},
                 glue={"stepdefinition"})

现在,我添加了新功能文件,“功能”文件夹如下所示:

Booking.feature
smoketest.feature

如何使用相同的运行器文件运行两个功能文件,或者必须为2个运行器创建新的运行器文件。

注意:最新功能文件是Booking.feature

更改标签名称时,这给我初始化错误

错误代码:

cucumber.runtime.CucumberException: java.lang.NoSuchMethodException: cucumber.runtime.java.JavaBackend.<init>(cucumber.runtime.io.ResourceLoader, io.cucumber.stepexpression.TypeRegistry)
    at cucumber.runtime.Reflections.newInstance(Reflections.java:53)
    at cucumber.runtime.Reflections.instantiateSubclasses(Reflections.java:35)
    at cucumber.runtime.Runtime.loadBackends(Runtime.java:89)
    at cucumber.runtime.Runtime.<init>(Runtime.java:42)
    at cucumber.api.junit.Cucumber.createRuntime(Cucumber.java:80)
    at cucumber.api.junit.Cucumber.<init>(Cucumber.java:59)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.NoSuchMethodException: cucumber.runtime.java.JavaBackend.<init>(cucumber.runtime.io.ResourceLoader, io.cucumber.stepexpression.TypeRegistry)
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.getConstructor(Class.java:1825)
    at cucumber.runtime.Reflections.newInstance(Reflections.java:45)
    ... 22 more

0 个答案:

没有答案