Coverage reporting helps you see which parts of your Django code are tested. It shows what is tested and what is not, so you can improve your tests.
Coverage reporting in Django
coverage run manage.py test coverage report coverage html
coverage run manage.py test runs your tests and collects coverage data.
coverage report shows a summary in the terminal.
coverage html creates a detailed report you can open in a browser.
myapp and collect coverage data.coverage run manage.py test myapp
coverage report -m
coverage html
This example shows the steps to run coverage on your Django tests. First, install the coverage tool. Then run your tests with coverage enabled. Next, see a summary report in the terminal. Finally, create a detailed HTML report.
1. Install coverage: pip install coverage 2. Run tests with coverage: coverage run manage.py test 3. Show coverage report: coverage report -m 4. Generate HTML report: coverage html
Make sure to install the coverage package before running coverage commands.
Run coverage commands from your Django project root where manage.py is located.
Use the HTML report to visually explore which lines are missing tests.
Coverage reporting shows which parts of your Django code are tested.
Use coverage run manage.py test to collect coverage data.
View results with coverage report or coverage html for detailed info.