HACKER Q&A
📣 jamil7

Do you enforce a unit test code coverage % in your CI/CD pipeline?


Previously I've never enforced unit testing, I wrote a lot myself and encouraged others to but didn't require it in code reviews. However my current team is much smaller and all onboard with doing TDD.

I understand the metric can be flakey and I'm not aiming for 100% but would like to know what number others aim for at and if you enforce it during code review or in CI/CD?


  👤 clintonb Accepted Answer ✓
We don’t have any automatic enforcement at my current company. At edX, and on personal projects, we used Codecov to enforce 95% coverage on all new code, and 95% coverage across the entire repo. The exact numbers varied with the current state of the repo, but this was the default for all new repos.

While the number was high, we did recognize when testing might cost more than it benefitted is, so we occasionally used comments to ignore coverage of some branches.


👤 byoung2
We don't enforce a % but new functionality won't pass code review without tests added. A previous company I worked for required 90% coverage enforced in CI/CD. It got annoying sometimes to refactor code so you could test every logic branch.