8 From executable specifications to automated acceptance tests

 

This chapter covers

  • The basic principles of automating your scenario steps
  • The responsibilities of a step definition method
  • Implementing step definitions using Cucumber in Java and TypeScript
  • Setting up virtual environments for your tests

Over the previous few chapters, you’ve seen how the BDD life cycle takes acceptance criteria and turns them into executable specifications. Acceptance criteria start as brief notes you write on the back of your story cards that help define when a story or feature is complete. During Three Amigos sessions or other requirements discovery workshops, these notes are fleshed out into more complete examples and counterexamples that illustrate business rules and objectives. And as we saw in the previous chapter, you can write more complete versions of these acceptance criteria in the form of Gherkin scenarios, using the Given ... When ... Then notation.1

8.1 Introduction to automating scenarios

8.1.1 Step definitions interpret the steps

8.2 Setting up your project

8.2.1 Setting up a Cucumber project in Java or TypeScript

8.2.2 Organizing a Cucumber project in Java

8.2.3 Organizing a Cucumber project in TypeScript

8.3 Running Cucumber scenarios

8.3.1 Cucumber test runner classes in Java

8.3.2 Running Cucumber scenarios in JavaScript and TypeScript

8.4 Writing glue code

8.4.1 Injecting data with step definition parameters

8.4.2 Making your Cucumber Expressions more flexible

8.4.3 Cucumber Expressions and custom parameter types

8.4.4 Using regular expressions

8.4.5 Working with lists and data tables

8.5 Setting up and tearing down with backgrounds and hooks