黄瓜中的重复步骤定义

Duplicate Step definition in cucumber

为什么 cucumber 比较相同的方法并给出重复步骤定义的错误

cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions in stepDefinitions.LogIn.SDLogin.inputUserCredentials() in file:/Users/nagarjunareddy/Documents/projectworkspace/eclipse/s360UIAutomationCC/target/classes/ and stepDefinitions.LogIn.SDLogin.inputUserCredentials() in file:/Users/nagarjunareddy/Documents/projectworkspace/eclipse/s360UIAutomationCC/target/classes/

在您描述的场景中,您有重复的 @When("^User enter the valid credentials$")。这通常发生在你有两个相似的步骤并且你复制并粘贴代码而忘记修改第二个步骤时特别是因为 IDE 无法知道这两个黄瓜步骤可能是重复的,你将不会得到 IDE警告。

再次检查,你应该有 1x @When("^User enter the valid credentials$") 和 1x @When("^User enter the inValid credentials$")

glue={"helpers","stepDefinitions"} 而不是 glue={"helpers","classpath/stepDefinitions", "classpath/stepDefinitions.LogIn","classpath/stepDefinitions.Publish"}

参考这个link Same issue on Github

恐怕问题出在具有两个相同步骤 "And Click on Login" 的 Login.feature 文件中。这是关于你的域相关设计的问题,但你可以简单地将步骤重写为 "And The invalid user clicks on Login" 和 "And the valid user clicks on Login".