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

Error: Couldn't map the 'ambiguous' to a Serenity Result #90

Closed
vijay-kumar-singh opened this issue Aug 29, 2017 · 5 comments
Closed

Error: Couldn't map the 'ambiguous' to a Serenity Result #90

vijay-kumar-singh opened this issue Aug 29, 2017 · 5 comments

Comments

@vijay-kumar-singh
Copy link

@vijay-kumar-singh vijay-kumar-singh commented Aug 29, 2017

Test throw error with 'Couldn't map the 'ambiguous' to a Serenity Result' and exit.
I have some common steps in multiple feature file and when i try to run all feature file together, i get
''Couldn't map the 'ambiguous' to a Serenity Result' error.
Example: let say i have to feature file profile.feature and account.feature with statement:
profile.feature
Given Log in option is available on home page
When Jack login to portal with validName@test.com and 1234
account.feature
Given Log in option is available on home page
When Jack login to portal with validName@test.com and 1234

When i run test, i get below error:
16:55:40.800 | ActivityStarts: When Jack login to portal with validName@test.com and 1234
When Jack login to portal with validName@test.com and 1234
[16:55:40] W/launcher - Ignoring uncaught error Error: Couldn't map the 'ambiguous' to a Serenity Result

Please suggest how to fix this or suggest if i am doing in wrong way. Its common that some steps could be similar in multiple feature file.

Regards,
Vijay Singh

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Aug 29, 2017

Hey Vijay,

This happens because you have more than one step definition matching one of the cucumber steps.

Cucumber marks this step as "ambiguous", passes that result to Serenity/JS, and Serenity/JS doesn't know what to do with it. Granted, it would probably improve developer experience if Serenity/JS complained saying "Looks like there's more than one step definition matching that step".

You can fix this problem by making sure there's no more than one step definition (in your steps.ts file) for any given step.

Hope that helps!
Jan

@vijay-kumar-singh
Copy link
Author

@vijay-kumar-singh vijay-kumar-singh commented Aug 30, 2017

Hi Jan,
Thank you for suggestion.

For now i have updated step definition and make it work.

But i am wondering, in case of large application(multiple features), where some common steps involve in multiple feature, like login before proceeding with feature, Cucumber will mark step as 'ambiguous'.
when we deal with large amount of stepdefs, we cannot guarantee we will not accidentally override previous stepdefs and that would certainly cause lots of troubles.
Could you please suggest how to handle 'ambiguous' error in above situation.

Regards,
Vijay

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Aug 30, 2017

Sure; "ambiguous" means that there's no way for Cucumber to figure out which step definition should be mapped to a step. The only real way of dealing with that is by making sure there's no such ambiguity and that there's only one step def that can be associated with a step.

In order to do that though the team needs some discipline around organising their step libraries (step def files) so that potentially ambiguous steps are easier to spot. For instance, you could group step definitions by feature so that related step defs live together - for example "authentication.steps.ts", "basket.steps.ts", "checkout.steps.ts", "account_management.steps.ts" etc.

Does that help?

Jan

Ps.
Having said that, Serenity/JS should probably still throw a "nicer" error...

@vijay-kumar-singh
Copy link
Author

@vijay-kumar-singh vijay-kumar-singh commented Aug 30, 2017

Thank you for suggestion Jan.
Its true that Cucumber throw 'ambiguous' error for ambiguous steps even if we group step definitions by features but one common steps available in those grouped features file.

Regards,
Vijay

@jan-molak
Copy link
Member

@jan-molak jan-molak commented Aug 30, 2017

No problem, happy to help. By the way, the next version of Serenity/JS will include better reporting around ambiguous steps.

jan-molak added a commit that referenced this issue Sep 17, 2017
…r.js

affects: @serenity-js/cucumber, @serenity-js/integration-testing

ISSUES CLOSED: #90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants