DEV Community

Discussion on: Do you aim for 80% code coverage? Let me guess which 80% you choose...

jcoelho profile image
José Coelho

Hmm very interesting position on code coverage.

In my short experience with unit testing, focusing on code coverage only frustrates and slows down developers.
I would rather aim for meaningful and purposeful tests, and coverage as a secondary goal.

Have you been able to keep 100% coverage on a project with other developers? Genuinely interested 😄

d_ir profile image
Daniel Irvine 🏳️‍🌈 Author

Thinking in terms of goals is something I’d agree with, and I also agree that coverage should be a secondary goal IF achieving it would be detrimental to team output. But I do think it’s an important aspirational goal for developers who want to get better at testing. (I’ve got another blog post about this topic, coming soon...)

I’ve worked for a TDD / XP consultancy before that always aimed for 100%. I don’t think they’d ever slip below 95%. I imagine that any company that is serious about TDD will be looking for close to 100% coverage.

Worth noting that you can still achieve 100% coverage in your OWN code (using TDD) even if the codebase overall doesn’t reach 100%.