tern
tern copied to clipboard
Increase Test Coverage
Problem Statement Currently, the test coverage for Tern's code is 63%. See below, which is a full coverage run on Tern's code base.
$ coverage run -m unittest discover -s tests
$ coverage report --fail-under 85
Name Stmts Miss Cover
-------------------------------------------------------------
tern/__init__.py 0 0 100%
tern/__main__.py 88 58 34%
tern/analyze/__init__.py 0 0 100%
tern/analyze/common.py 247 213 14%
tern/analyze/docker/__init__.py 0 0 100%
tern/analyze/docker/analyze.py 99 79 20%
tern/analyze/docker/container.py 105 57 46%
tern/analyze/docker/dockerfile.py 108 57 47%
tern/analyze/docker/helpers.py 103 79 23%
tern/analyze/docker/run.py 93 74 20%
tern/analyze/passthrough.py 44 31 30%
tern/classes/__init__.py 0 0 100%
tern/classes/command.py 74 7 91%
tern/classes/docker_image.py 105 16 85%
tern/classes/image.py 75 13 83%
tern/classes/image_layer.py 103 5 95%
tern/classes/notice.py 32 0 100%
tern/classes/notice_origin.py 44 0 100%
tern/classes/origins.py 31 0 100%
tern/classes/package.py 71 1 99%
tern/classes/template.py 9 0 100%
tern/command_lib/__init__.py 0 0 100%
tern/command_lib/command_lib.py 158 122 23%
tern/report/__init__.py 0 0 100%
tern/report/content.py 46 37 20%
tern/report/errors.py 33 0 100%
tern/report/formats.py 47 0 100%
tern/report/report.py 84 55 35%
tern/utils/__init__.py 0 0 100%
tern/utils/cache.py 38 24 37%
tern/utils/constants.py 19 0 100%
tern/utils/general.py 86 20 77%
tern/utils/rootfs.py 164 74 55%
tests/test_analyze_docker_dockerfile.py 48 1 98%
tests/test_class_command.py 84 1 99%
tests/test_class_docker_image.py 48 5 90%
tests/test_class_image.py 62 1 98%
tests/test_class_image_layer.py 74 1 99%
tests/test_class_notice.py 38 1 97%
tests/test_class_notice_origin.py 48 1 98%
tests/test_class_origins.py 60 1 98%
tests/test_class_package.py 100 1 99%
tests/test_class_template.py 37 1 97%
tests/test_fixtures.py 41 0 100%
tests/test_util_general.py 23 1 96%
-------------------------------------------------------------
TOTAL 2769 1037 63%
Describe the Proposal More tests need to be written for Tern. Ideally we would have a coverage for 85% of the code, although, this is up for debate. (I think 80% could be acceptable).
Steps to Implement Proposal Look at files with low % coverage and add tests for them. This will likely not happen all in one PR. Once coverage is up to an acceptable passing rate, merge in PR #530 and re-add the test for GH Actions.
We can add this as a GSoC stretch goal. There is a chance that the current ideas can be completed and still have time left during GSoC.
Working on this right now! :muscle:
Should i submit a PR per element (cache, files, packages, metadata) or group allof them in one PR? I prefer first option to allow me progress in others test in case some testcase needs more work or isn't valid.