If you use python and GitLab like I do, you can include a test coverage report in your CI/CD pipeline. You pip install coverage and then just run coverage in your pipeline. The following is an excerpt from an AWS lambda pipeline, but you should be able to find something similar for your environment:
- pip install -r ./awslambda/requirements.txt
There aren't any off the shelf solution currently that allows you to specify a variable number of code coverage percentage.
There is the tool Courtney which enforces 100% code coverage. This tool also allows you to comment on blocks of code which do not need to be covered.
The issue has been resolved.
This is for nodejs
Need to install necessary dependencies either using yarn or npm.
Once done, run
nyc --reporter=lcov yarn unit unit
$ ./cc-test-reporter after-build -t lcov --exit-code $?
This is my opinion: Coverage says nothing about correctness, so if you are writing unit tests for coverage, you are doing it wrong. Unit tests shall originate in requirements, the resulting coverage is a measure for completeness of your test suite and your code quality. If the coverage is low, chances are that
your unit tests don't cover all requirements.
The way I would approach this would be to have a second part of the junit test that reads the generated zip file and then verifies it is correct. You are right that if you are only ensuring you can generate the file, but the file is incorrect, the unit test is incomplete.