Reputation:
My project has a structure like:
root/
.coveragerc
folder_a/
folder_b/
tests/
folder_a/
folder_b/
I would like to run coverage
against folder_a
and folder_b
. Is possible to run it in a single command? Something like pytest --cov=* tests/ --cov-report html
...
Upvotes: 27
Views: 19695
Reputation: 1675
I'm posting the answer from @hoefling here because I didn't see the answer in the comment at first and saw it later when I looked at all the comments.
To specify coverage for multiple folders, provide the --cov
multiple times:
pytest --cov=folder_a --cov=folder_b --cov=folder_c
Upvotes: 35
Reputation: 1672
I found this to work well. It runs coverage.py using pytest:
coverage run -m pytest
This was run at the project fodler. It was able to find the folder called tests, and run all the tests (which was split into multiple python files) within them. To see the report run:
coverage report
Upvotes: -1
Reputation: 565
Yes it is possible.
For example,
for a structure,
> proj_folder
- > tests_functional
- > tests_unit
Example
$ pytest --cov=proj_folder proj_folder/tests_unit proj_folder/tests_functional
Syntax
$ pytest --cov=<proj_folder/package_name> <proj_folder>/tests_unit <proj_folder>/tests_functional
Upvotes: 0