The unittest is a unit testing framework in Python. It supports multiple tasks such as test fixtures, writing test cases, aggregating test cases into the test suites, and running tests.
unittest supports four main concepts, which are listed here:
- test fixture: This includes preparation and cleanup activities for performing one or more tests
- test case: This includes your individual unit test. By using the TestCase base class of unittest, we can create new test cases
- test suite: This includes a collection of test cases, test suites, or both. This is for executing test cases together
- test runner: This includes arranging the test executions and giving output to the users
Python has a unittest module that we will import in our script. The unittest module has TestCase class for creating test cases.
Individual test cases can be created as methods. These method names...