Test coverage
A test coverage report is useful in determining the percentage of our code that was executed in the course of testing. Let’s install the coverage
module so we can measure whether our API was adequately tested:
(venv)$ pip install coverage
Next, let’s generate a coverage report by running this command:
(venv)$ coverage run -m pytest
Here’s the result:
Next, let’s view the report generated by the coverage run -m pytest
command. We can choose to view the report on the terminal or a web page by generating an HTML report. We’ll do both.
Let’s review the report from the terminal:
(venv)$ coverage report
Here’s the result:
From the preceding report, the percentages signify the amount of code executed and interacted with. Let’s generate the HTML report...