Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grasshopper7/cuke-wrap-scenariooutline
Wrapping a ScenarioOutline with setup and teardown by splitting examples table
https://github.com/grasshopper7/cuke-wrap-scenariooutline
cucumber cucumber-jvm gherkin
Last synced: 7 days ago
JSON representation
Wrapping a ScenarioOutline with setup and teardown by splitting examples table
- Host: GitHub
- URL: https://github.com/grasshopper7/cuke-wrap-scenariooutline
- Owner: grasshopper7
- Created: 2018-06-10T09:03:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-03T05:38:39.000Z (over 1 year ago)
- Last Synced: 2024-11-07T12:26:41.136Z (about 2 months ago)
- Topics: cucumber, cucumber-jvm, gherkin
- Language: Java
- Homepage: http://grasshopper.online/126/
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Refer to this for a detailed explanation - http://ghchirp.site/126/
This uses the concept of splitting ScenarioOutline tables into separate Example sections to surround with a setup and teardown method.
Let's try to model an atheletics relay race (4X100m) into a Cucumber scenario. A simple approach would be to repeat steps for each runner, leading to a long scenario with repeation. So how about using a scenariooutline and extracting the common variables, like number of runner and from to end distance marker for each runner. Possibly something similar to below.
Scenario Outline:
Given runner baton in hand
When Runner starts running
Then Runner runs required
Examples:
| runner | distmarker | state |
| First | 100 | has |
| Second | 200 | gets |
| Third | 300 | gets |
| Last | 400 | gets |
Looks pretty good, but it does not take into account that the first runner begins from the start line. Also the last runner crosses the finish line. If these two steps are added to the existing ScenarioOutline, it will not provide the ideal solution.Scenario Outline:
Given runner baton in hand
When Runner starts running
Then Runner runs required
@First
Examples:
| runner | distance | state |
| First | 100 | has |Examples:
| runner | distance | state |
| Second | 200 | gets |
| Third | 300 | gets |@Last
Examples:
| runner | distance | state |
| Last | 400 | gets |
The Examples table is now split into three, with the first and the last given the tags. Use this tags to run @Before and @After hooks, modelling the unique requirements.@Before("@First")
public void startLine() {
//First runner is at start line
}
@After("@Last")
public void finishLine() {
//Last runner crosses finish line
}
These hooks will then act as setup and teardown methods.