When you should NOT write Unit Tests

If you are developing a new product or a feature nearly from scratch and you are wondering if you should spend time writing UTs. You are probably thinking the right thing. (IMHO, if you think that you should always write UTs, you might be wasting a lot of time)

Let me try to keep this short and crisp:

  1. Typically if you are developing something new where features will keep getting added, subtracted really fast. You might realize that the core components might have to change. And not just change but might also vanish and new design components might also appear.
  2. So now your product is ready to go to the market and you just deployed your app on one of the hosting providers out there and you are now facing scaling issues – your app hangs when the traffic is on peak, you get 1000s of errors in the peak traffic time, your app is a memory hog and the GC runs a little too much.  All of this is happening and you are thinking of major strategic design changes to make your code light-weight and stable.
  3. Your product is now out there, does not hang too often. But you still see tons of errors in the logs.

Depending on how many surprises you are expecting in stage 1,2 and 3, you should delay writing UTs in the initial phases of the launch of your new app / feature.

And how many surprises you expect depends on how new is the app you are going to launch, in terms of the core design components, the kind of traffic its going to receive, the new features that you expect to go in and out in the initial launch phase.

I have had experience where we ended up writing lot of UTs while we were in phase 1 and then it became harder and harder to maintain the UTs sanity during 1,2. We realized that the kind of speed with which the design was evolving was a little too much to keep the UTs sane.

Once your app has crossed stage 3, you know you should start adding UTs for sure. At the same time be really careful, the later you start with the UTs the bigger would be the overhead of making a solid UT framework stand from ground-up.  To be honest, there is never too late for writing UTs, but there surely is too early, so understand your app and make your judgement call.

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