DEV Community

loading...

Discussion on: Test Coverage - going from bad to good, and knowing when to do it

Collapse
tisek profile image
tisek⚓

Is it really possible to cover untested code?
And to cover years of code that is untested which also means it was not designed to be testable and therefore is tough to test?

From my experience, in the end we cover new features (that do not rely on too much old code) and easy to test code (helper classes or very small modules).

Covering the whole thing takes tremendous time not only of test writing but also massive refactoring to get it to be testable. Problem is, we do not have tests to cover our asses while refactoring so the risk is really high.

Of course keeping untested old code is risky too...

At the end of the day, I believe that being in the situation of a big codebase with very little testing is awful with very little hope of improvement (does not mean we should not try)...

Collapse
_bigblind profile image
Frederik 👨‍💻➡️🌐 Creemers

s it really possible to cover untested code?
And to cover years of code that is untested which also means it was not designed to be testable and therefore is tough to test?

I'd go with the Scouts mentality of leaving code better than you found it. Add tests when you're touching a piece of code, so you can already edit it to be more testable. Yes that might be a slightly risky refactor because it's not covered by tests, but then again, it's no more risky than the development you did before TDD.