-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adds scenario for the ambiguous step reporting #1132
Adds scenario for the ambiguous step reporting #1132
Conversation
@enkessler could you please review it? :D |
Thanks @MadameSheema! I think we need to have a look at exactly what we want the behaviour for ambiguous steps to be. I think the choice is that the step is either Pending or Failed. This PR recommends Failed. It could be pending because the user needs to give Cucumber more information so that it can decide what to run here. It could be failed because there is a problem with the test automation code and Cucumber is unable to execute the step. |
With |
I think Cucumber-Ruby should do what Cucumber-JS does and have a result type for Ambiguous. Without |
It sounds like we'll need at least three scenarios here:
I'm pretty sure guess mode has always just quietly done its job in the past. I think we should focus on helping @MadameSheema get this back to working and then deal with making guess mode more fancy. WDYT? |
* a step | ||
* an ambiguous step | ||
|
||
Scenario: test 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why we need this second scenario. I'd find it easier to read this example if it wasn't there. Do we need it to illustrate the behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matt it's there because the current behaviour is that it just crashes the whole test run and doesn't run he second scenario.
I suppose that if it reported the status correctly it wouldn't matter how many scenarios there are.
""" | ||
Feature: | ||
|
||
Scenario: test 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to not even bother naming scenarios used as tests unless it adds something to the documentation. In this case I suggest you can leave it blank.
@@ -0,0 +1,63 @@ | |||
Feature: Ambiguous Steps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you tag this feature as @wip
then (I think) it will be expected to fail in CI, so your branch will stay green. Once we have it passing we can remove the @wip
tag.
@@ -0,0 +1,63 @@ | |||
Feature: Ambiguous Steps | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add some documentation here about this feature. Something like:
When Cucumber searches for a step definition for a step, it might find multiple step
definitions that could match. In that case, it will give you an error that the step
definitions are ambiguous.
You can also use a `--guess` mode, where it uses magic powers to try and figure
out which of those two step definitions is most likely to be the one you meant it
to use. Use it with caution!
@charlierudolph do you alter the behaviour of cucumber-js for ambiguous steps depending on |
@brasmusson I agree about having an Ambiguous result type. |
In cucumber-js ambiguous steps cause a build to fail by default (thus they are more similar to failed steps then undefined / pending), @jbpros and I debated that here: cucumber/cucumber-js#442. Thus the behavior does not change depending on strict mode. |
Based on Charlie's comment then I suggest we stay consistent with JS, keep it simple and ignore strict mode for now. So only two scenarios needed - with / without guess mode |
e0d7784
to
97082b2
Compare
@mattwynne could you please take a look to the scenarios? thx :) |
I like this much better now! I'm wondering why you've used the |
You can run again with --guess to make Cucumber be more smart about it | ||
(Cucumber::Ambiguous) | ||
|
||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the other thing that's important for this scenario is to see the summary report:
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
0m0.012s
I think we see an error like this in the current behaviour, but it also drops out of the running cucumber process and doesn't print the summary report?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tooky right now, when we have an ambiguous step and we execute it without the guess mode the summary report is not displayed. I can add it as an expected behaviour :)
Is there anything else we should take into consideration for this scenario? Thx!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MadameSheema I think we should. The issue that we based this PR on #1113 was reported because the current behaviour is wrong. When we are running without --guess
we want to report this as a failed step, and continue the run as normal. So we should see the summary.
Thanks for sticking with this!
@mattwynne because the example we started working on it was written like that 😊 |
It looks like the problem here is that the I think the change for this needs to be done in It's probably a matter of altering the method here to understand about ambiguous steps. We could probably use a similar mechanism to the It's going to take some fiddling around with, and might need a spike / pairing session with someone who knows the code well to avoid a lot of head-scratching. This is essentially a regression from when we went from 1.0 to 2.0 and rewrote a lot of the internals. Unfortunately because this didn't have an acceptance tests we never noticed. Thanks for adding one @MadameSheema! |
a591f3b
to
e1c1200
Compare
Taught Cucumber how to match against ambiguous steps.
lib/cucumber/step_match.rb
Outdated
end | ||
|
||
def activate(test_step) | ||
return test_step.with_action { raise Core::Test::Result::Ambiguous.new(@error.message) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the return keyword doing anything here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that return value of a Ruby method is the last thing evaluated? No, it's just there because that's how someone wrote the code that I am basing this code on.
I don't necessarily understand why established patterns are there, but I can at least follow them as I attempt to fix code that I am entirely unfamiliar with. :)
What does the failing test say now? Can you paste the output you're seeing when you run it? |
@mattwynne Currently we see
but we expect something like
which is basically what it is already doing except for shoving in the helpful error snippet. This error is already made in the error class itself
but it's not getting output anywhere. From what I have seen of the code, I think that outputting it happens somewhere in |
The PR should be rebased to take advantage of the ground work in #1158.
This is printed by the formatter, so (some of) the formatters need to be updated to handle To get something up and running I recommend using the |
Hi @MadameSheema, Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾 In return for we ask you to:
On behalf of the Cucumber core team, |
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. |
Summary
Added scenario about how the reporting of ambiguous step match should be. See #1113
Details
Spike of an example we think reporting could be.
Motivation and Context
Fixes #1113
Types of changes
Checklist: