Writing Scenarios
Tables Simplify Repetitive Scenarios
The workflow style that we saw on the previous page can be quite repetitive.There is a better way and it's called a scenario table:
- Columns represent inputs and outputs
- Each row represents one complete scenario
Scenario Outline: User calculates result with overflow detected
Given the calculator is cleared
And the user enters <x>
And the user presses <operation>
And the user enters <y>
When the user presses equals
Then the result should be <result>
Examples:
| x | operation | y | result |
| 3 | add | 4 | 7 |
| -1 | add | 1 | 0 |
| 99999999 | add | 1 | Error |
| -3 | multiply | -4 | 12 |
| 50000000 | multiply | -2 | Error |
Tables work well to describe a series of input/output scenarios.
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |