
Ask HN: Do you enforce a unit test code coverage % in your CI/CD pipeline? - jamil7
Previously I&#x27;ve never enforced unit testing, I wrote a lot myself and encouraged others to but didn&#x27;t require it in code reviews. However my current team is much smaller and all onboard with doing TDD.<p>I understand the metric can be flakey and I&#x27;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&#x2F;CD?
======
clintonb
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.

~~~
jamil7
Do you enforce that automatically? or is it just part of the review process?

~~~
byoung2
At my current company, just part of the review process people will not approve
your PR if there are no tests. My last company enforced it in CI and you could
not merge if there was less than 90% coverage.

