Chapter 3. Mastering the Given-When-Then template
This chapter covers
- Writing scenarios for the real world
- Using realistic data in scenarios
- Understanding advanced rules for using Given-When-Then
- Getting unstuck when writing scenarios
- Generating ideas for new scenarios
In chapter 2, we explored the two layers of executable specifications: the specification layer and the automation layer. We focused on the specification layer and writing it. But if you ever tried to write a blog post, you know that just writing and great writing aren’t the same thing. Likewise, writing scenarios and writing great scenarios can be quite different.
This chapter will teach you to write great scenarios. Chapter 2 taught you the basics of the Given-When-Then template, and this chapter is an advanced course. Expressive scenarios incorporate a vivid vocabulary of domain language that helps readers understand requirements more easily. But Gherkin’s syntax is so easy that sometimes it seems repetitive—and therefore boring. Boring scenarios are easier to skim. You must learn to write expressive scenarios if you are to establish a connection with your readers.