Advanced cucumber features
Learn about the following cucumber features:
- Doc Strings ("multiline strings") Show archive.org snapshot
- Tables Show archive.org snapshot
- Tags Show archive.org snapshot
- Before/after hooks Show archive.org snapshot
- Background Show archive.org snapshot
- Scenario outlines Show archive.org snapshot
Think of a practical application for each feature. If you can't think of one, discuss it with your mentor.
Also read through the card How to not repeat yourself in Cucumber scenarios.
Cucumber Factory
We have a very useful gem to create test data in cucumber: cucumber_factory Show archive.org snapshot .
Read through the README.
Integrate it into your MovieDB and replace your custom model creation steps with Cucumber Factory.
Simplify your Cucumber features
Look through your MovieDB features and step definitions. Can you spot opportunities to apply what you learnt?
- Can you move duplicate steps to a
Background
or turn scenarios into aScenario outline
? - Can you use a Harness in your step definitions? Is it worth it?
If you cannot find any opportunities to DRY up a Cucumber scenario, do this exercise (testing the file upload from before):
- Write a scenario:
User can upload a movie poster in PNG format
- Write a scenario:
User can upload a movie poster in JPG format
- DRY up both scenarios in a single scenario outline with two examples
Note
In practice the file extension check should belong in a unit test, not an E2E test.