DannyMoshe
DannyMoshe

Reputation: 6255

How to prevent coverage.py in Django from resetting coverage between runs?

Searched the docs, but couldnt find a way to do this. I've been running my test suite with the following command:

coverage manage.py run test tests

This will run all tests in the 'tests' folder. Following this, to measure coverage I use the report command:

coverage report -m

The issue is that this measurement is completely reset between runs. So lets say i run all of my tests in the suite and achieve 85% coverage. If i then run/re-run an individual testcase/testmethod, the coverage measurement is reset so the report will only show coverage for that particular testcase/testmethod that was last run.

Per my usage, the only way to get an up-to-date coverage measurement is to re-run all test cases (this takes a long time). Is there a way to have the coverage measurement store previous results, and only modify coverage for results of subsequently run tests?

Upvotes: 0

Views: 151

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375574

From the docs:

By default, each run of your program starts with an empty data set. If you need to run your program multiple times to get complete data (for example, because you need to supply disjoint options), you can accumulate data across runs with the -a flag on the run command.

-a can also be --append.

Upvotes: 1

Related Questions