Working with Python test frameworks
Python comes with standard as well as third-party libraries for test automation. The most popular frameworks are listed here:
pytest
unittest
doctest
nose
These frameworks can be used for unit testing as well as for integration and system testing. In this section, we will evaluate two of these frameworks: unittest
, which is part of the Python standard library, and pytest
, which is available as an external library. The focus of this evaluation will be on building test cases (mainly unit tests) using these two frameworks, although the integration and system tests can also be built using the same libraries and design patterns.
Before we start writing any test cases, it is important to understand what a test case is. In the context of this chapter and book, we can define a test case as a way of validating the outcomes of a particular behavior of a programming code as per the expected results. The development of a test case...