On Thu, Jan 14, 2010 at 1:08 PM, Jonatas P.
| step | description |
| 1 | first |
| 2 | second |
I want to execute Given, When and Then once before start with Scenario
Outline Iterator. This steps are running for each row. How can I create
a subscenario or something like that?
Do you have a concrete example? That would make it easier to find a
There’s a way to do it?
Here are some approaches that might be worth looking into.
Given-When-Then statements are functions that can call each other. Have
look at this example (
to see what I mean. When calling steps from a step definition, it’s a
idea to keep the step types consistent. In other words, avoid calling a
Then statement from a Given statement definition. Compound steps may
what you need because they will run once for each iteration of the
If you want a set of Givens to run only once for the entire Scenario
Outline, use Background (
downside here is Background statements are run before each Scenario
(Outline) in the Feature, thereby restricting the Scenarios you can use
Lastly, take a look at Tagged Hooks (
http://wiki.github.com/aslakhellesoy/cucumber/hooks). These can be used
you want some Ruby code to run before (or after) every Scenario with a
particular tag. A big downside here is there’s no indication, aside
the tag, that additional Ruby code is running. You can get the same
using a Given statement, which is certainly clearer than a Hook.