Hacker News new | ask | show | jobs
by notepalf 1554 days ago
Why is 100% coverage stupid? I agree that there could be configuration or data classes that does not make sense to test, so these could be ignored by the coverage tool. Is it still stupid to aim for 100% coverage in the rest of the relevant not-ignored code?
2 comments

100% coverage as a measure of success is stupid.

And (this gets into personal opinions) sacrificing depth on tests on critical codepaths in order to spend time getting to 100% coverage is also stupid.

Time is finite. Money is finite. 100% coverage provides nothing but false assurances and pretty green metric lights.

100% coverage measured by lines of code being hit is actually insufficient for proper test coverage (which is what most, if not all tools that measure code coverage do).

It's easy to get "100% code coverage" for the below function:

  def nths(number: int, divisor: int) -> float:
      return number/divisor

  def test_nths():
      assert nths(1, 1) == 1
Yet it's obvious that test is not really taking care of anything.

What you need is 100% semantic coverage, i.e. your tests should cover all potential outcomes of the code at appropriate levels.