-1

Why cucumber compares same method and gives error as duplicate step definitions

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/ project structurenavigation feature fileenter image description here enter image description here

Nagarjuna Reddy
  • 759
  • 9
  • 19
  • 39
  • updated the screen shot. 1. Project Structure 2,3 Feature files 4. Step definition file **User enter the valid credentials** points to the same step definition in the step definition file – Nagarjuna Reddy May 22 '17 at 11:18
  • If the file isn't too long; instead of using screenshots, please post your SDLogin.java code here. – nugenjs May 22 '17 at 16:44

4 Answers4

3

glue={"helpers","stepDefinitions"} instead of glue={"helpers","classpath/stepDefinitions", "classpath/stepDefinitions.LogIn","classpath/stepDefinitions.Publish"}

Refer this link Same issue on Github

Nagarjuna Reddy
  • 759
  • 9
  • 19
  • 39
2

In the scenario you described, you have duplicate @When("^User enter the valid credentials$"). That usually happens when you have two similar steps and you copy&paste code and forget to modify the second one Especially since the IDE is not capable of knowing those two cucumber steps may be duplicates, you will get no IDE warnings.

Check again, you should have 1x @When("^User enter the valid credentials$") and 1x @When("^User enter the inValid credentials$")

nugenjs
  • 155
  • 2
  • 10
0

I'm afraid the problem is in the Login.feature file which has the two same steps "And Click on Login". It's the problem about your domain-related design, but simply you can rewrite the steps into "And The invalid user clicks on Login" and "And the valid user clicks on Login".

Tonny Tc
  • 852
  • 1
  • 12
  • 37
0

Solution: Just give a full path of your Step Definition file which you are running, in glue parameter value, so that cucumber will not get confused if there is same step is used in another Step Definition files.

Ashish Gupta
  • 105
  • 1
  • 5