Skip to content

Commit 5c93c4d

Browse files
committed
📝 Add tip not to omit tests from coverage
1 parent a0d9c58 commit 5c93c4d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/test/pytest/coverage.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,28 @@ Alternatively, this can also be configured for all occurrences:
304304
`Configuration reference
305305
<https://coverage.readthedocs.io/en/latest/config.html>`_
306306

307+
.. _coverage_tip:
308+
309+
.. tip::
310+
Many people exclude tests from test coverage: `omit tests
311+
path:**/pyproject.toml
312+
<https://github.com/search?q=omit+tests+path%3A**%2Fpyproject.toml&type=code>`_.
313+
However, this is a bad idea. Your tests are real code, and the whole point of
314+
test coverage is to give you information about your code. Why wouldn’t you
315+
want this information about your tests?
316+
317+
You might say, *‘All my tests run the entire code, so it’s useless
318+
information.’* However, if you write a new test and copy an existing test for
319+
it, changing only the execution but not the function name, only one of the
320+
two test functions will be executed. And are you sure that every piece of
321+
helper code in your test suite is still needed? Coverage would alert you to
322+
this problem in both cases.
323+
324+
One argument against test coverage is that it artificially inflates the
325+
reports. But you can easily exclude these files from the report with
326+
`[report] skip_covered
327+
<https://coverage.readthedocs.io/en/latest/config.html#report-skip-covered>`_.
328+
307329
Extensions
308330
----------
309331

0 commit comments

Comments
 (0)