Module: check_mk
Branch: master
Commit: 1da55649d847fd6acf3d863fc5c8f2e0d0a5188f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1da55649d847fd…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Mon Apr 16 16:42:53 2018 +0200
Add coverage target for pytest unit tests
Generate HTML report for (pytest) unit test coverage.
---
tests/.coveragerc_unit | 14 ++++++++++++++
tests/Makefile | 22 +++++++++++++---------
2 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/tests/.coveragerc_unit b/tests/.coveragerc_unit
new file mode 100644
index 0000000..b417f89
--- /dev/null
+++ b/tests/.coveragerc_unit
@@ -0,0 +1,14 @@
+[run]
+source =
+ ../active_checks
+ ../agents
+ ../bin
+ ../checkman
+ ../checks
+ ../cmk
+ ../cmk_base
+ ../enterprise/cmk/cee
+ ../tests/unit
+ ../web
+branch = True
+
diff --git a/tests/Makefile b/tests/Makefile
index ceff31e..2aca780 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,18 +1,20 @@
SHELL=/bin/bash -e
-PYTEST=source $$(pipenv --venv)/bin/activate ; py.test -s -vv
+PYTEST=source ../.envrc ; py.test -s -vv
+COVERAGE=source ../.envrc ; coverage
.PHONY: help test-pylint test-integration test-gui-crawl \
test-bandit test-shellcheck setup format test-mypy \
- test-pylint-simple test-unit test-packaging
+ test-pylint-simple test-unit test-unit-coverage test-packaging
help:
- @echo "setup - Install dependencies"
- @echo "test-unit - Run unit tests"
- @echo "test-pylint - Run pylint based tests"
- @echo "test-integration - Run integration tests"
- @echo "test-gui-crawl - Run GUI crawl test"
- @echo "test-bandit - Run bandit (security) tests"
- @echo "test-shellcheck - Run shellcheck tests"
+ @echo "setup - Install dependencies"
+ @echo "test-unit - Run unit tests"
+ @echo "test-unit-coverage-html - Create HTML coverage report for unit
tests"
+ @echo "test-pylint - Run pylint based tests"
+ @echo "test-integration - Run integration tests"
+ @echo "test-gui-crawl - Run GUI crawl test"
+ @echo "test-bandit - Run bandit (security) tests"
+ @echo "test-shellcheck - Run shellcheck tests"
# This target needs to be phony so it is run every time because only the other
# makefile can determine that there's nothing to be done.
@@ -25,6 +27,8 @@ help:
test-unit: ../.venv
$(PYTEST) -T unit
+test-unit-coverage-html: ../.venv
+ $(COVERAGE) run --rcfile=.coveragerc_unit -m pytest -T unit ; $(COVERAGE) html
test-integration: ../.venv
$(PYTEST) -T integration