Capturing a succinct story in a
doctest file is the key to BDD. Another aspect of BDD is providing a readable report including the results.
For this recipe, we will be using the shopping cart application shown at the beginning of this chapter.
With the following steps, we will see how to write a custom
doctest runner to make our own report.
recipe28_cart_with_no_items.doctestto contain our
doctestscenario that exercises the shopping cart.
This scenario demonstrates a testable story. First, we need to import the modules >>> from cart import * >>> cart = ShoppingCart() #when we add an item >>> cart.add("carton of milk", 2.50) #doctest:+ELLIPSIS ...