-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Adds scenario for the ambiguous step reporting #1132
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
Merged
brasmusson
merged 11 commits into
cucumber:master
from
MadameSheema:1123-scenario_gracefully_reporting_ambiguous_steps
Aug 2, 2017
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1a5ddb3
Adds scenario for the ambiguous step reporting
GloriaHornero 452e2cd
Adds @wip tag
GloriaHornero 77ebe87
Adds feature documentation
GloriaHornero af9a5ab
Simplifies tests scenarios by removing the scenario name
GloriaHornero d980346
Adds ambiguous tests with guess mode scenario
GloriaHornero 5242c69
Simplifies ambiguous steps scenario
GloriaHornero c233450
Improves test scenarios by adding keywords
GloriaHornero f3660a1
Adds summary report to ambiguous steps scenario
GloriaHornero e1c1200
Adds @wip tag to ambiguous steps scenario
GloriaHornero b39f24f
Add ambiguous step matching
enkessler 041536a
Fix the feature and implementation of ambiguous steps.
brasmusson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
Feature: Ambiguous Steps | ||
|
||
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! | ||
|
||
|
||
Scenario: Ambiguous steps | ||
|
||
Given a file named "features/ambiguous.feature" with: | ||
""" | ||
Feature: | ||
|
||
Scenario: | ||
When a step | ||
Then an ambiguous step | ||
|
||
""" | ||
And a file named "features/step_definitions.rb" with: | ||
""" | ||
When(/^a.*step$/) do | ||
'foo' | ||
end | ||
|
||
Then(/^an ambiguous step$/) do | ||
'bar' | ||
end | ||
|
||
""" | ||
When I run `cucumber` | ||
Then it should fail with: | ||
""" | ||
Ambiguous match of "an ambiguous step": | ||
|
||
features/step_definitions.rb:1:in `/^a.*step$/' | ||
features/step_definitions.rb:5:in `/^an ambiguous step$/' | ||
|
||
You can run again with --guess to make Cucumber be more smart about it | ||
(Cucumber::Ambiguous) | ||
features/ambiguous.feature:5:in `Then an ambiguous step' | ||
|
||
Failing Scenarios: | ||
cucumber features/ambiguous.feature:3 # Scenario: | ||
|
||
1 scenario (1 failed) | ||
2 steps (1 failed, 1 passed) | ||
0m0.012s | ||
|
||
""" | ||
|
||
|
||
Scenario: Ambiguous steps with guess mode | ||
|
||
Given a file named "features/ambiguous.feature" with: | ||
""" | ||
Feature: | ||
|
||
Scenario: | ||
When a step | ||
Then an ambiguous step | ||
""" | ||
And a file named "features/step_definitions.rb" with: | ||
""" | ||
When(/^a.*step$/) do | ||
'foo' | ||
end | ||
|
||
Then(/^an ambiguous step$/) do | ||
'bar' | ||
end | ||
""" | ||
When I run `cucumber -g` | ||
Then it should pass with exactly: | ||
""" | ||
Feature: | ||
|
||
Scenario: # features/ambiguous.feature:3 | ||
When a step # features/step_definitions.rb:1 | ||
Then an ambiguous step # features/step_definitions.rb:5 | ||
|
||
1 scenario (1 passed) | ||
2 steps (2 passed) | ||
0m0.012s | ||
|
||
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.