Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5 from msassak/master
Browse files Browse the repository at this point in the history
cucumber-features: hooks.feature
  • Loading branch information
msassak committed Aug 28, 2011
2 parents a6cfdd3 + 17f887e commit ce6c5e7
Showing 1 changed file with 45 additions and 22 deletions.
67 changes: 45 additions & 22 deletions hooks.feature
@@ -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

0 comments on commit ce6c5e7

Please sign in to comment.