This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
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
1 changed file
with
45 additions
and
22 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 |
---|---|---|
@@ -1,22 +1,45 @@ | ||
Feature: Hooks | ||
Cucumber provides a number of hooks which allow us to run blocks at various | ||
points in the Cucumber test cycle. You can put them in your support/env.rb | ||
file or any other file under the support directory, for example in a file | ||
called support/hooks.rb. There is no association between where the hook is | ||
defined and which scenario/step it is run for, but you can use tagged hooks | ||
if you want more fine grained control. | ||
|
||
Scenario: General before hook | ||
Given a before hook that causes an error | ||
And a step definition matching /^a step passes$/ | ||
When I run the following feature: | ||
""" | ||
Feature: A before hook runs before every scenario | ||
Scenario: The hook runs before this scenario | ||
Given a step passes | ||
Scenario: The hook also runs before this scenario | ||
Given a step passes | ||
""" | ||
Then the feature should have 2 failing scenarios | ||
And 2 skipped steps | ||
Feature: Environment Hooks | ||
|
||
Cucumber provides a number of hooks which allow you to | ||
configure the environment for your application. By | ||
default hooks are run for each scenario, but you can use | ||
tagged hooks if you want more fine grained control. | ||
|
||
Scenario: Before and After | ||
Given a passing before hook | ||
And a passing after hook | ||
When Cucumber executes a scenario | ||
Then the before hook is fired before the scenario | ||
And the after hook is fired after the scenario | ||
|
||
Scenario: Around | ||
Given a passing around hook | ||
When Cucumber executes a scenario | ||
Then the around hook fires around the scenario | ||
|
||
Scenario: Around fires around other hooks | ||
Given a passing around hook | ||
And a passing before hook | ||
And a passing after hook | ||
When Cucumber executes a scenario | ||
Then the around hook is fired around the other hooks | ||
|
||
Scenario: Tagged hook with matching scenario tag | ||
Given a hook tagged with "@foo" | ||
When Cucumber executes a scenario tagged with "@foo" | ||
Then the hook is fired | ||
|
||
Scenario: Tagged hook without matching scenario tag | ||
Given a hook tagged with "@foo" | ||
When Cucumber executes a scenario tagged with "@bar" | ||
Then the hook is not fired | ||
|
||
Scenario: Tagged hook with untagged scenario | ||
Given a hook tagged with "@foo" | ||
When Cucumber executes a scenario with no tags | ||
Then the hook is not fired | ||
|
||
Scenario: Untagged hook with tagged scenario | ||
Given an untagged hook | ||
When Cucumber executes a scenario tagged with "bar" | ||
Then the hook is fired |