Think about what coverage tools measure: code execution, not test success or database queries.
Coverage percentage shows how many lines of your Python code ran during tests. It does not measure test success or database queries.
Remember the order: coverage run runs a command, then coverage html generates the report.
The correct syntax is coverage run manage.py test to run tests with coverage, then coverage html to create the HTML report.
coverage run manage.py test but the coverage report shows 0% coverage. What is the most likely cause?Think about how coverage tracks code execution and what happens if it is not properly started.
If coverage is not properly started before running tests, it won't track code execution, resulting in 0% coverage.
Name Stmts Miss Cover ----------------------------------------- myapp/views.py 50 10 80% myapp/models.py 30 0 100% myapp/forms.py 20 5 75%
How many lines of code were missed in total?
Add the missed lines from each file.
Missed lines are 10 + 0 + 5 = 15 total missed lines.
Think about what migrations are and why testing them is usually unnecessary.
Migrations are generated by Django to change the database schema. They are not hand-written logic and usually don't need coverage measurement.