For the next exercises, you need to install a small plugin:
:::bash
pip install pytest-cov
Calculate the percentage of code covered by automatic tests:
:::bash
pytest --cov=.
Instead of the .
you can insert the path you would like to see in the coverage report.
Check whether any hidden files have appeared.
Find out which lines are not covered by tests. Execute
:::bash
coverage html
Open the resulting file htmlcov/index.html
in a web browser.
Write more tests to increase the test coverage of word_counter.py
to 100%.
- does 100% test coverage mean that the program is free of bugs?
- does 100% test coverage mean that all execution paths in the program have been tested?
- what types of errors is a high test coverage most likely to avoid?