Right now the way I'm running things is I have a set of test cases written with pytest that I run, if they fail then I fix and rework on. If they pass I use pytest-cov to get coverage and manually decide whether coverage is good enough. I was wondering if it was possible for pytest to fail if threshold for coverage is under x amount.
pytest --cov=myproject tests --cov-report=html
coverage report --fail-under=80
....
myproject/services/subnet.py 36 33 8%
myproject/severity.py 5 0 100%
--------------------------------------------------------------------------------------------------------------------
TOTAL 8843 8739 1%
....
You should use pytest for running tests, and failing if the tests fail. Then use coverage to assess the coverage amount, and fail if it is under:
pytest --cov=mypackage --cov-report= tests-or-whatever
coverage report --fail-under=80
If you are using pytest-cov
, you can use --cov-fail-under=MIN
:
pytest --cov-fail-under=80 [...]
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