Behavior testing or integration testing is a good method of implementing end-to-end black box testing. One popular framework for this type of testing is Cucumber (https://cucumber.io/), which uses the Gherkin language to describe the steps to a test in English, and then implements those steps in code. Go has a Cucumber library as well (github.com/DATA-DOG/godog). This recipe will use the godog package to write behavior tests.
Getting ready
Configure your environment according to these steps:
- Refer to the Technical requirements section at the beginning of this chapter.
- Run thego get github.com/DATA-DOG/godog/cmd/godog command.
How to do it...
These steps cover writing and running your application:
- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter9/bdd, and navigate to this directory.
- Run the following...