Testing myth: “The code is so simple – it doesn’t need a test”

If the code is so simple, then it will be simple to test it.

And at some point, it’s likely the feature will be enhanced. If there is an existing test then it should be simple to enhance it. If there isn’t an existing test then things can quickly get messy.

The more complex the code, the harder it is to introduce tests.

This is the TDD approach: get something simple working, then enhance it in a simple way, and repeat until you have what you want. Lots of small, simple (and testable) steps.

OK, not all code needs a test. (Auto-generated accessors, simple wrapper methods, etc). But still, be mindful of the myth!

Leave a Reply Cancel reply

Exit mobile version
%%footer%%