Skip to main content

Unit Test are at least as important as the Code itself: Part II

Posted by schaefa on November 3, 2004 at 11:35 AM PST

In one of the comments to the original blog about Unit Tests I was told that tests can never be as important as the code itself. I want to use this opportunity to explain a little bit more why I still think that developers should pay way more attention to testing even thought that test code is not delivered and/or sold.

In our complex world many items are more than what is visible to us and we often take these hidden things for granted. For example our good old money the paper bills are quite simple and consists of a piece of paper with the issuing country, the currency and amount printed on. The money is a proxy for a value we can use to exchange against items we like to buy. Despite the fact that our money is pretty worthless the general acceptance as a proxy of a certain value makes it so sought after. In order to keep our trust into our money intact countries spend a lot of efforts on fighting counterfeiting. This hidden service, and other services, keeps a printed piece of paper valuable. In contrast during the German Hyperinflation in 1923 the government started to print excessive amounts of money inflating their currency and making it more or less worthless.

Now when I choose software I expect two things:

  • The software is doing what it says it is doing
  • The software is working and does not harm my hardware, software or any data

Of course, there are more attributes I am looking for like the price etc but these two are very important. Like with money these two attributes determine the value of the software and my level of confidence into it. If software is doing something else that what I need it for or when it is buggy or even worse compromise my computer and data it render useless to me. In my point of view it does not matter how much time and effort was put into its creation. In addition most of the software I am using has a certain history allowing me to choose certain software based on the experience I had with previous versions or with other software from the same vendor. So I dumped the Internet Explorer and replaced it with Mozilla's Firefox even thought it is a beta version.

Unit Tests helps to make software reliable, helps to detect problems early and prevents regression. Tests do not guarantee a bug-free software but it makes a huge difference in the user experience with the software when bugs only appear once and overall the product seems to be quite stable. If tests are writing in a test-driven-development style meaning you write your tests ahead of the actual coding it helps you to design you code towards the client's needs. Finally, late testing like done by the QA department or the customer costs more time and money that when it would be found by the developer. With it the costs of software development can be reduced with good and early testing and frees the developer to work on new and exciting features rather than fixing nasty bugs.

To make a long story short Unit Tests are a part of the software shipped even the test code is not part of it. The tests influence will be visible in the product in a very pleasant experience improving the value of your software more that one might think. Good tests will change the delivered code in many ways and so, indirectly, it is shipped, too. In case the tests fail to do so there are most likely not worth the disk space they are stored on. I do not deny the fact that the success of software does not only depend on the reliability of but also on the marketing and timing. Nevertheless it would be a pity if you loose customers because of buggy software after you got their attention and willingness to give it a shot.

Happy testing - Andy