Friday, 17 August 2012

It's all production

Every now and then, I come across a discussion about whether test code deserves as much care as production code. I understand what is meant (the answer is yes), but I don't accept the premise of the question.

All code is production code. Deployment scripts, tests, database migrations and Java controllers all play a part in delivering value to the users. If a piece of code really has no effect on production, why was it ever written?


  1. I don't think tests are production code. They are the scaffold that supports production. In code review I don't scrutinise them so much and I don't hold them to the same code quality; I'm mainly looking at whether they test the right things.

    The other area of code we don't really value as production code is for any components needed to support demo and manual testing - effectively mocked versions of components we have no other way of developing against (including mocked human interactions).

  2. All code is scaffold that supports production, one way or the other. I understand the distinction you're making, but I don't think it's helpful.

    The reason you write code cleanly is so that you can change it without fear. If I can't do that, then my ability to deliver value to production will be compromised, regardless of what role the code plays.

    I've treated tests and fakes with disrespect in the past, but I've always regretted it.

  3. The analogy I come across in the past and found really useful in this context is that of a space rocket. You might argue that all you wanted is the command module on the moon (in production) but it would be ridiculous that first, second and third stage (the supporting infrastructure, tests and so on) doesn't play a vital part in getting there.

  4. I somehow missed this comment when you first made it, Marcin, bu that's a great way of putting it.