Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambigous step definition error with new version of cucumber #682

Closed
madhurissanap opened this issue Mar 14, 2014 · 14 comments
Closed

Ambigous step definition error with new version of cucumber #682

madhurissanap opened this issue Mar 14, 2014 · 14 comments

Comments

@madhurissanap
Copy link

Hello All

I am getting following error , where as this was working fine with previous release of cucumber jvm version.

Given I logged in with UN and PW on RedBus on page # CommonSteps.logingInRedBusServices()
[java] cucumber.runtime.AmbiguousStepDefinitionsException: ?.Given I logged in with UN and PW on RedBus on page(Authenticate/AuthenticateRedBusUser.feature:8) matches more than one step definition:
[java] I logged in with UN and PW on RedBus in CommonSteps.logingInRedBusServices()
[java] I logged in with UN and PW on RedBus on page in ToKnowSeatsAvailability.logingInRedBusServices()

in Fixture i have following step definitions in two seperate files
@given("I logged in with UN and PW on RedBus")
public void logingInRedBusServices() throws Exception {
//Code
}

@Given("I logged in with UN and PW on RedBus on page")
 public void logingInRedBusServices() throws Exception  {
    //Code  
  } 
@aslakhellesoy
Copy link
Contributor

Please be specific about what versions you are talking about.

It has never been possible to have ambiguous step definitions, so I don't understand how this can ever have worked. In any case - this is by design.

Feel free to hop on the cukes google group to discuss further.

@madhurissanap
Copy link
Author

I added following list of jars
cucumber-java-1.1.5
cucumber-html-0.2.3
cucumber-java-1.1.5
cucumber-junit-1.1.5
cucumber-jvm-deps-1.0.3

where this was working fine with 1.1.2 version

@aslakhellesoy
Copy link
Contributor

And what versions were you using when you didn't get the error?

@madhurissanap
Copy link
Author

I didnt get error in following versions
cucumber-core-1.1.2.jar
cucumber-html-0.2.2.jar
cucumber-java-1.1.2.jar
cucumber-junit-1.1.2.jar

@aslakhellesoy
Copy link
Contributor

I find it very hard to believe that 1.1.2 would have allowed ambiguous step definitions.

In any case - how do you expect Cucumber to choose among the two stepdefs that match your step?

@madhurissanap
Copy link
Author

Since these are two different steps , thus it should consider these as two different step
Also these steps does have any regular expression to be considered as ambigous.
Please let me if i can send you project

@madhurissanap
Copy link
Author

Can you please share a drive or location where i can share the project where it works with older version of cucumber

@aslakhellesoy
Copy link
Contributor

Just create a github repo and push your code there. Then past a link to the repo here.

@brasmusson
Copy link
Contributor

The change in #485 explains why the AmbiguousStepDefinitionsException appear in v1.1.5 but not in v1.1.2. Since Cucumber-JVM now support partial matching (for the rationale see tip 8), the solution is to anchor at least the shorter step definition regex:

@Given("I logged in with UN and PW on RedBus$")
public void logingInRedBusServices() throws Exception {
//Code
} 

then it will not match the longer step:
Given I logged in with UN and PW on RedBus on page

@aslakhellesoy
Copy link
Contributor

Thanks Björn! It's hard to keep track of everything. I should have read the changelog more carefully.

@madhurissanap
Copy link
Author

Thank you. I was just wondering why would user have a same step definition for different steps.

In the Issue #466 user could have created a step defnition with regular expresion and use the same step across the features.

I can have two different steps with two different step defnitions

I navigate to (.*) page

I navigate to (.*) page via parent page

It would be great if changes of issue #466 reverted.

@madhurissanap
Copy link
Author

Hello All,

Any views on this issue, can issue 466 be reverted?

@aslakhellesoy
Copy link
Contributor

@madhurissanap no we are not going to revert that. Did you try anchoring your regular expressions like @brasmusson suggested?

Regarding your question about why you would use the same step definition in different steps, please read https://github.com/cucumber/cucumber/wiki/Feature-Coupled-Step-Definitions-(Antipattern)

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants