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!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s