I've got a python program which is tested by running it several times with different inputs, and comparing the outputs against reference results.
I'd like to get code coverage of all the tests combined, so I can see if there are extra sets of inputs I should be using to get complete coverage. I've looked at the coverage module but can't work out how I can make it do this.
Any clues?
You can merge coverage data from multiple runs with -a/--add-tracefile . If you want to merge coverage reports generated in different --root directories you can use the --json-base to get the same root directory for all reports.
Code coverage is a simple tool for checking which lines of your application code are run by your test suite. 100% coverage is a laudable goal, as it means every line is run at least once. Coverage.py is the Python tool for measuring code coverage.
If running on the same machine, run it with the -a
option, which accumulates coverage data across multiple calls.
Example:
coverage erase
coverage run -a <command> [arguments, ...]
coverage run -a <command> ... # repeat as many times as needed.
coverage report
coverage html
doc: http://coverage.readthedocs.org/en/latest/cmd.html#data-file
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With