O'Reilly logo

Python Testing Cookbook. by Bhaskar N. Das, Greg L. Turnquist

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

The following steps will show how to write scenarios in a format other than HTML tables and also how to tag tests to allow picking and choosing which tests are run on the command line:

  1. Create a new file called recipe41.txt using plain text and space-separated entries that has a couple of test cases: a simple one and another a more complex one with documentation and tags:
***Test Cases***Simple check of adding one item    Given an empty cart    When I add a carton of milk for 2.50    Then the total with 0 % tax is 2.50    And the total with 10 % tax is 2.75More complex by storing cart to database    [Documentation] This test case has special tagging, so it can beexcluded. This is in case the developer doesn't have the right databasesystem ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required