-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add coverage reporting to tests #917
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[run] | ||
source = ansible_runner | ||
data_file = test/coverage/data/coverage | ||
|
||
[report] | ||
skip_covered = True | ||
skip_empty = True | ||
|
||
[html] | ||
directory = test/coverage/reports/html | ||
|
||
[xml] | ||
output = test/coverage/reports/coverage.xml | ||
|
||
[json] | ||
output = test/coverage/reports/coverage.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
# Mac OS X | ||
*.DS_Store | ||
# Test artifacts | ||
*.py,cover | ||
.pytest_cache/ | ||
docs/_build/ | ||
docs/build/ | ||
pytestdebug.log | ||
test/coverage/ | ||
|
||
# Byte-complied files | ||
*.py[cod] | ||
__pycache__/ | ||
|
||
# Editors | ||
*.sw[poj] | ||
*~ | ||
/.idea | ||
# Distribution / packaging | ||
*.egg | ||
*.egg-info/ | ||
.eggs/ | ||
AUTHORS | ||
Changelog | ||
build/ | ||
deb-build/ | ||
dist/ | ||
eggs/ | ||
rpm-build/ | ||
|
||
# Environments | ||
.env | ||
.python-version | ||
.tox/ | ||
.venv | ||
env/ | ||
venv/ | ||
|
||
# Demo files | ||
/demo/artifacts | ||
/demo/daemon.log | ||
/docs/_build | ||
/.tox | ||
/dist | ||
/build | ||
/rpm-build | ||
/deb-build | ||
/*.egg-info | ||
*.py[c,o] | ||
.pytest_cache | ||
pytestdebug.log | ||
.coverage | ||
*,cover | ||
.venv | ||
/venv | ||
.env | ||
/.eggs/ | ||
docs/build | ||
AUTHORS | ||
ChangeLog |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ addopts = | |
--durations 10 | ||
--durations-min 1 | ||
--strict-markers | ||
--cov | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @samdoran I also recommend adding an explicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another comment is that you should measure the coverage for both the project and the tests. For this, you'd need to use a few subsequent args: Here's what the coveragepy author posted last year: https://nedbatchelder.com/blog/202008/you_should_include_your_tests_in_coverage.html. |
||
--cov-report html | ||
--cov-report term | ||
samdoran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--cov-report xml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pytest | ||
pytest-cov | ||
pytest-mock | ||
pytest-timeout | ||
pytest-xdist | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,12 @@ description = Build documentation | |
deps = -r{toxinidir}/docs/requirements.txt | ||
commands = | ||
sphinx-build -T -E -W --keep-going {tty:--color} -j auto -d docs/build/doctrees -b html docs docs/build/html | ||
|
||
[testenv:clean] | ||
description = Erase docs and coverage artifacts | ||
deps = | ||
skip_install = True | ||
allow_external = /bin/sh | ||
commands = | ||
/bin/sh -c "rm -rf {toxinidir}/test/coverage/*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @samdoran I have a few comments here:
|
||
/bin/sh -c "rm -rf {toxinidir}/docs/{_,}build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you may need
parallel = True
andbranch = True
as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
branch = True
, yes I should add that.parallel = True
is being set bypytest-cov
.