From 75b09a71ac033780fc91e9701ce291233018b02e Mon Sep 17 00:00:00 2001 From: Randy Barlow Date: Jan 21 2019 14:01:38 +0000 Subject: Document how to configure pytest to measure coverage. Signed-off-by: Randy Barlow --- diff --git a/docs/dev-guide/writing-tests.rst b/docs/dev-guide/writing-tests.rst index b632eb1..a7aac15 100644 --- a/docs/dev-guide/writing-tests.rst +++ b/docs/dev-guide/writing-tests.rst @@ -157,6 +157,13 @@ percentage goes down. This example ``.coveragerc``:: omit = my_python_package/tests/* +To configure ``pytest`` to collect coverage data on your project, edit +``setup.cfg`` and add this block, substituting ``yourpackage`` with the name +of the Python package you are measuring coverage on:: + + [tool:pytest] + addopts = --cov-config .coveragerc --cov=yourpackage --cov-report term --cov-report xml --cov-report html + causes coverage (and any test running plugins using coverage) to fail if the coverage level is not 100%. New projects should enforce 100% test coverage. Existing projects should ensure test coverage does not drop to accept a pull