-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This ensures that prepare world is the first thing that is run for a test case, preventing the inconsistency with what the world _is_ in around hooks. Legacy adapter requires each test case to have a test step otherwise it doesn't switch step container and messages get lost. Also ensures failures in Around hooks are reported.
- Loading branch information
Showing
6 changed files
with
232 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,80 @@ | ||
Feature: Exceptions in Around Hooks | ||
|
||
Around hooks are awkward beasts to handle internally. | ||
|
||
Right now, if there's an error in your Around hook before you call `block.call`, | ||
we won't even print the steps for the scenario. | ||
|
||
This is because that `block.call` invokes all the logic that would tell Cucumber's | ||
UI about the steps in your scenario. If we never reach that code, we'll never be | ||
told about them. | ||
|
||
There's another scenario to consider, where the exception occurs after the steps | ||
have been run. How would we want to report in that case? | ||
|
||
Scenario: Exception before the test case is run | ||
Given the standard step definitions | ||
And a file named "features/support/env.rb" with: | ||
""" | ||
Around do |scenario, block| | ||
fail "this should be reported" | ||
block.call | ||
end | ||
""" | ||
And a file named "features/test.feature" with: | ||
""" | ||
Feature: | ||
Scenario: | ||
Given this step passes | ||
""" | ||
When I run `cucumber -q` | ||
Then it should fail with exactly: | ||
""" | ||
Feature: | ||
Scenario: | ||
this should be reported (RuntimeError) | ||
./features/support/env.rb:2:in `Around' | ||
Failing Scenarios: | ||
cucumber features/test.feature:2 | ||
1 scenario (1 failed) | ||
0 steps | ||
0m0.012s | ||
""" | ||
|
||
Scenario: Exception after the test case is run | ||
Given the standard step definitions | ||
And a file named "features/support/env.rb" with: | ||
""" | ||
Around do |scenario, block| | ||
block.call | ||
fail "this should be reported" | ||
end | ||
""" | ||
And a file named "features/test.feature" with: | ||
""" | ||
Feature: | ||
Scenario: | ||
Given this step passes | ||
""" | ||
When I run `cucumber -q` | ||
Then it should fail with exactly: | ||
""" | ||
Feature: | ||
Scenario: | ||
Given this step passes | ||
this should be reported (RuntimeError) | ||
./features/support/env.rb:3:in `Around' | ||
Failing Scenarios: | ||
cucumber features/test.feature:2 | ||
1 scenario (1 failed) | ||
1 step (1 passed) | ||
0m0.012s | ||
""" |
This file contains 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 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 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 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 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