Determining test coverage
In the previous recipes, test case writing was covered, but there is an important aspect to measure the extent of testing, called coverage. Coverage refers to how much of our code has been covered by the tests. The higher the percentage of coverage, the better the testing (although high coverage is not the only criterion for good tests). In this recipe, we will check the code coverage of our application.
Tip
Remember that 100% test coverage does not mean that code is flawless. However, in any case, it is better than having no tests or lower coverage. Remember that “if it’s not tested, it’s broken.”
Getting ready
We will use a library called coverage
for this recipe. The following is the installation command:
$ pip install coverage
How to do it…
The simplest way of measuring code coverage is to use the command line:
- Simply run the following command:
$ coverage run --source=<Folder name of the...