Todd uses an earlier grocery list application as an example of how to adapt to BDD using Cucumber, giving one example of a feature:
Feature: Shopper can add an item to their Grocery List
Scenario: Item added to grocery list
Given I have an empty grocery list
When I add an item to the list
Then the grocery list contains a single item
The feature defines a business value, while the scenario defines the steps that provide that value. Each scenario has a list of steps defined by the keywords Given, When, Then; steps that CucumberJS will execute after having read the feature specification.
Using CucumberJS together with NodeJS, Todd walks through some examples of implementing and running the grocery list application while moving from all tests failing to all pass.
Todd concludes with a belief that there is a reward in having code under a test harness when it comes to refactoring and bug fixing, and with an ambition to follow up with new posts addressing how he uses CucumberJS to run tests integrating with a browser.
BDD was developed around 2006 by Dan North.