richa verma
richa verma

Reputation: 287

Generate code and test coverage report separately without running coverage run twice

I am running coverage,py tool to get code coverage. Using command,


     COVERAGE_FILE=.coverage_dir coverage run -a --omit */tests/* ./manage.py test --settings=dir.tests.settings_unittest

I can view reports using, coverage report --data-file=.coverage_dir

This gives me coverage report of python source files. If I don't omit tests, I will get coverage report for both source and test files.

I want to have separate tests and code coverage report. If it is possible that I have to run the command only once.

So that in the end I can just run

coverage report --data-file=.coverage_dir
coverage report --data-file=.coverage_test

to view the reports and get html reports.

Upvotes: 0

Views: 2713

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375854

You can use the --include option on the report command. Use coverage run once without the --omit option, then:

coverage report --include='tests/*'
coverage report --include='the_product/*'

Upvotes: 2

Related Questions