I'm wondering if it's possible to combine coverage.xml
files into 1 file to see global report in HTML output.
I've got my unit/functional tests
running as 1 command and integration tests
as the second command. That means my coverage for unit/functional tests
are overridden by unit tests
.
That would be great if I had some solution for that problem, mainly by combining those files into 1 file.
You can achieve same result by using appending option. Suppose you ran the coverage on three python scripts.After first coverage use -a for appending.
Print the report
Output:Report
You can't combine .xml files, but you can combine the raw data files. Your workflow would look like this:
I found a different solution. I used
combine
feature (read here) So I run my coverage like:coverage run -p
and then I docoverage combine
.That's all. It generates 1 combined report.
If your source code is in a directory called
my_project
, you can also do this if you have includedpytest
andpytest-cov
in your virtual environment:The
--cov-append
will add the functional test coverage info to the coverage file that was created when you ran the unit tests.Use -a option with coverage run command. eg : coverage run -a test1.py This will append the results to existing coverage file, verify the same by doing coverage report