Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
527 additions
and
28 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,97 @@ | ||
Feature: After Block Exceptions | ||
In order to use custom assertions at the end of each scenario | ||
As a developer | ||
I want exceptions raised in After blocks to be handled gracefully and reported by the formatters | ||
|
||
Background: | ||
Given a standard Cucumber project directory structure | ||
And a file named "features/step_definitions/steps.rb" with: | ||
""" | ||
Given /^this step does something naughty$/ do | ||
@naughty = true | ||
end | ||
Given /^this step works$/ do | ||
end | ||
""" | ||
And a file named "features/support/env.rb" with: | ||
""" | ||
class NaughtyScenarioException < Exception; end | ||
After do | ||
if @naughty | ||
raise NaughtyScenarioException.new("This scenario has been very very naughty") | ||
end | ||
end | ||
""" | ||
|
||
Scenario: Handle Exception in standard scenario step and carry on | ||
Given a file named "features/naughty_step_in_scenario.feature" with: | ||
""" | ||
Feature: Sample | ||
Scenario: Naughty Step | ||
Given this step does something naughty | ||
Scenario: Success | ||
Given this step works | ||
""" | ||
When I run cucumber features | ||
Then it should fail with | ||
""" | ||
Feature: Sample | ||
Scenario: Naughty Step # features/naughty_step_in_scenario.feature:3 | ||
Given this step does something naughty # features/step_definitions/steps.rb:1 | ||
This scenario has been very very naughty (NaughtyScenarioException) | ||
./features/support/env.rb:4:in `After' | ||
Scenario: Success # features/naughty_step_in_scenario.feature:6 | ||
Given this step works # features/step_definitions/steps.rb:5 | ||
2 scenarios (1 failed, 1 passed) | ||
2 steps (2 passed) | ||
""" | ||
|
||
Scenario: Handle Exception in scenario outline table row and carry on | ||
Given a file named "features/naughty_step_in_scenario_outline.feature" with: | ||
""" | ||
Feature: Sample | ||
Scenario Outline: Naughty Step | ||
Given this step <Might Work> | ||
Examples: | ||
| Might Work | | ||
| works | | ||
| does something naughty | | ||
| works | | ||
Scenario: Success | ||
Given this step works | ||
""" | ||
When I run cucumber features | ||
Then it should fail with | ||
""" | ||
Feature: Sample | ||
Scenario Outline: Naughty Step # features/naughty_step_in_scenario_outline.feature:3 | ||
Given this step <Might Work> # features/step_definitions/steps.rb:5 | ||
Examples: | ||
| Might Work | | ||
| works | | ||
| does something naughty | | ||
This scenario has been very very naughty (NaughtyScenarioException) | ||
./features/support/env.rb:4:in `After' | ||
| works | | ||
Scenario: Success # features/naughty_step_in_scenario_outline.feature:12 | ||
Given this step works # features/step_definitions/steps.rb:5 | ||
4 scenarios (1 failed, 3 passed) | ||
4 steps (4 passed) | ||
""" | ||
|
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,99 @@ | ||
Feature: AfterStep Block Exceptions | ||
In order to use custom assertions at the end of each step | ||
As a developer | ||
I want exceptions raised in AfterStep blocks to be handled gracefully and reported by the formatters | ||
|
||
Background: | ||
Given a standard Cucumber project directory structure | ||
And a file named "features/step_definitions/steps.rb" with: | ||
""" | ||
Given /^this step does something naughty$/ do | ||
@naughty = true | ||
end | ||
Given /^this step works$/ do | ||
end | ||
""" | ||
And a file named "features/support/env.rb" with: | ||
""" | ||
class NaughtyStepException < Exception; end | ||
AfterStep do | ||
if @naughty | ||
raise NaughtyStepException.new("This step has been very very naughty") | ||
end | ||
end | ||
""" | ||
|
||
Scenario: Handle Exception in standard scenario step and carry on | ||
Given a file named "features/naughty_step_in_scenario.feature" with: | ||
""" | ||
Feature: Sample | ||
Scenario: Naughty Step | ||
Given this step does something naughty | ||
Scenario: Success | ||
Given this step works | ||
""" | ||
When I run cucumber features | ||
Then it should fail with | ||
""" | ||
Feature: Sample | ||
Scenario: Naughty Step # features/naughty_step_in_scenario.feature:3 | ||
Given this step does something naughty # features/step_definitions/steps.rb:1 | ||
This step has been very very naughty (NaughtyStepException) | ||
./features/support/env.rb:4:in `AfterStep' | ||
features/naughty_step_in_scenario.feature:4:in `Given this step does something naughty' | ||
Scenario: Success # features/naughty_step_in_scenario.feature:6 | ||
Given this step works # features/step_definitions/steps.rb:5 | ||
2 scenarios (1 failed, 1 passed) | ||
2 steps (1 failed, 1 passed) | ||
""" | ||
|
||
Scenario: Handle Exception in scenario outline table row and carry on | ||
Given a file named "features/naughty_step_in_scenario_outline.feature" with: | ||
""" | ||
Feature: Sample | ||
Scenario Outline: Naughty Step | ||
Given this step <Might Work> | ||
Examples: | ||
| Might Work | | ||
| works | | ||
| does something naughty | | ||
| works | | ||
Scenario: Success | ||
Given this step works | ||
""" | ||
When I run cucumber features | ||
Then it should fail with | ||
""" | ||
Feature: Sample | ||
Scenario Outline: Naughty Step # features/naughty_step_in_scenario_outline.feature:3 | ||
Given this step <Might Work> # features/step_definitions/steps.rb:5 | ||
Examples: | ||
| Might Work | | ||
| works | | ||
| does something naughty | | ||
This step has been very very naughty (NaughtyStepException) | ||
./features/support/env.rb:4:in `AfterStep' | ||
features/naughty_step_in_scenario_outline.feature:4:in `Given this step <Might Work>' | ||
| works | | ||
Scenario: Success # features/naughty_step_in_scenario_outline.feature:12 | ||
Given this step works # features/step_definitions/steps.rb:5 | ||
4 scenarios (1 failed, 3 passed) | ||
4 steps (1 failed, 3 passed) | ||
""" | ||
|
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
Oops, something went wrong.