I'm running a set of tests with pytest
and want also to measure its coverage with the coverage
package.
I have some decorators in my code, dividing the tests in several suites using something like:
@pytest.mark.firstgroup
def test_myfirsttest():
assert True is True
@pytest.mark.secondgroup
def test_mysecondtest():
assert False is False
I need to find something like:
coverage run --suite=firstgroup -m pytest
So that in this case only the first test, since it's in the correct suite, will be used to test coverage.
The suites work correctly when I use directly pytest
but I don't know how to use them in coverage
Is there any way to configure coverage
to achieve this?
You can pass whatever arguments you want to pytest. If this line works:
pytest --something --also=another 1 2 foo bar
then you can run it under coverage like this:
coverage run -m pytest --something --also=another 1 2 foo bar