Scenario tables are similar to Fit's ColumnFixture and NUnit's RowTest. You run the same scenario with different inputs each time.
Let's go back to our plain text feature and add the following.
Scenario Outline: score should be as per the std rules
Given I am starting a new game
When my rolls are <rolls>
Then the score should be <score>
Scenarios: lets go bowling
| rolls | score |
|5 2 | 7 |
|5 5 5 | 15 |
The key things to remember here are the 'Scenario Outline:' marker to indicate that it is an outline. We then have placeholders within angular brackets. The Outline is then followed by one or more tables identified by the marker 'Scenarios:'
The next line should contain column headers which correspond with the placeholders in the outline. Cucumber would substitute the values to run each row against the Outline.
SARC and it should fail. Let's go fix that up in bowling_game.rb
@score = 0
def roll( pins_knocked_down)
@score += pins_knocked_down
SARC. Now you should see this nice listing.
You can tag a scenario (or a feature) with one (or more) tags.
Feature: Bowling Game Score Calculation
In order to let the player know his score
By default, cucumber runs all .feature files in the features subfolder. You can group features in different subfolders as well e.g. I can define a new.feature within a new_features subfolder, which can then be run with
Overtime, it can get crowded with lots of subfolders. But tagging is here to save the day..
To run only features/scenarios marked 'fast'
>cucumber --tags @fast
To run features/scenarios that are not marked 'fast'
>cucumber --tags ~@fast
So that's another way to quickly sort out your tests.
The next thing you'd probably want to know (just in case you need it) is that cucumber speaks multiple languages. You can write your .feature file in any language - provided that the necessary entries are made in the resource file - languages.yml.
Next post - getting cucumber to test a .Net app with some help from IronRuby. Piqued?
Resources on BDD / Cucumber (although I felt the majority were too entwined with Rails (e.g. WebRat for testing Web Apps via free step definitions) but then that very well could be the major user-base for cucumber right now.)