Chapter 2. The specification layer and the automation layer
This chapter covers
- Understanding an executable specification’s layers
- Understanding the structure of those layers
- Writing your first Given-When-Then scenarios
- Exploring how the specification layer interacts with testing code
If you haven’t worked with Gherkin and specification by example (SBE) before, chapter 1 may have shown you your first Gherkin scenario (listing 1.1). We haven’t yet written a full Gherkin specification document together, though, and we’ll need more practical examples to do that.
Chapter 1 also talked about how conversations captured in Gherkin become automated tests and how automation keeps executable specifications up to date. But we didn’t discuss any details. What does automation mean in the context of SBE? How can you automate conversations? Are there any tools you can use? These are all legitimate questions.
In this chapter, you’ll learn to write a simple executable specification from scratch. Throughout the chapter, you’ll work on an example of a calendar application that schedules meetings for its users. (Think Google Calendar.) You’ll write a simple scenario about what it takes to create new meetings. By doing so, we’ll also explore the basics of the relationship between the two layers of every executable specification, in order to understand the technical limitations behind the Given-When-Then template.