When I run my tests, I realised that pytest-cov only shows coverage reports for files that are touched during the automated tests. How can I set it so that it shows coverage for even files that are not touched?
When I run my tests, I realised that pytest-cov only shows coverage reports for files that are touched during the automated tests. How can I set it so that it shows coverage for even files that are not touched?
I had the exact same issue.
Make sure you have a __init__.py file in every subdirectory (package).
More info: why you want __init__.py files.
My pyproject.toml file for reference:
[tool.pytest.ini_options]
addopts = [
"--cov=mypackage",
"--cov-report=term-missing",
]
output:
Name Stmts Miss Cover Missing
----------------------------------------------------------------------------
src/mypackage/__init__.py 4 0 100%
src/mypackage/sub/__init__.py 0 0 100%
src/mypackage/sub/mod1.py 23 23 0% 1-33
src/mypackage/sub/mod2.py 41 41 0% 1-61
[...]