为什么我在黄瓜测试中得到“ DuplicateStepDefinitionException”?

时间:2019-01-02 11:30:53

标签: java intellij-idea cucumber

我正在采取一些措施,而我一直遇到这个问题:[i for i in lst if not set(stop_words) & set(i.split(' '))] ['Mark Rich']]

我试图用自己的双手纠正此问题,但没有任何效果,有关此异常的问题并没有帮助我纠正问题。

我的错误所在:

DuplicateStepDefinitionException

堆栈跟踪:

public abstract class FicheSteps<T extends FicheBean, U extends ServiceFicheBO> implements Fr{
    protected T bean;
    protected U service;

    public FicheSteps() {    
    When("user want to create a {}", (EnumExtension extension) -> {
        TestUtils.navigateToContenu(extension);
        service.getScreenBO().createContent();
    });
}

我注意到的一件奇怪的事是重复的异常出现在同一步骤定义中:

cucumber.runtime.CucumberException: Failed to instantiate class fr.kosmos.selenium.cucumber.stepdefs.fiche.ActualiteSteps

    at cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:47)
    at cucumber.runtime.java.DefaultJavaObjectFactory.getInstance(DefaultJavaObjectFactory.java:33)
    at cucumber.runtime.java.JavaBackend.buildWorld(JavaBackend.java:122)
    at cucumber.runner.Runner.buildBackendWorlds(Runner.java:120)
    at cucumber.runner.Runner.runPickle(Runner.java:38)
    at cucumber.api.testng.TestNGCucumberRunner.runScenario(TestNGCucumberRunner.java:68)
    at fr.kosmos.selenium.cucumber.KSupCucumberTestCase.runCucumberTest(KSupCucumberTestCase.java:61)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at 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 org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    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:1208)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
    at org.testng.TestNG.runSuites(TestNG.java:1049)
    at org.testng.TestNG.run(TestNG.java:1017)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
Caused by: java.lang.reflect.InvocationTargetException
    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 cucumber.runtime.java.DefaultJavaObjectFactory.cacheNewInstance(DefaultJavaObjectFactory.java:41)
    ... 30 more
Caused by: cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions in FicheSteps.java:27 and FicheSteps.java:27
    at cucumber.runner.Glue.addStepDefinition(Glue.java:30)
    at cucumber.runtime.java.JavaBackend.addStepDefinition(JavaBackend.java:159)
    at cucumber.api.java8.Fr.Quand(Fr.java:3985)
    at fr.kosmos.selenium.cucumber.api.FicheSteps.<init>(FicheSteps.java:27)
    at fr.kosmos.selenium.cucumber.stepdefs.fiche.ActualiteSteps.<init>(ActualiteSteps.java:19)
    ... 35 more

重要的是,直到今天,黄瓜在所有这些步骤中都运转良好。 有什么想法吗?

0 个答案:

没有答案