Unit Tests Are Not Like Wine
Unit tests are not like wine. They do not get better with age. If ignored long enough, they become futile and stray down to the outskirts of code society. This is a diluted reference to unit test maintenance during development. But in order to understand exactly how unit tests work, we first need to slightly touch the topic of vinification.
Grapes are harvested and taken into a winery and are fermented. Key ingredient of wine is the must (or pulp) of the grape, which is fermented together with the grape skin. Fermentation is done by adding yeast, and during a process which lasts roughly around two weeks, yeast turns the sugar into alcohol and carbon dioxide. The gas is lost but the alcohol remains with the pulp and skin. After this, the mix is pressed again and the remaining pulp is extracted; then the wine is kept warm and fermentation continues. Finally there is secondary fermentation, which is achieved with bacteria, which in this stage focuses on turning malic acids into lactic acids. This process is the key to fine tuning the final taste of the wine.
As we can see, the process is refined and fine tuned reaching a complexity that can hardly be compressed in just a few words. The aging process which continues inside the bottle is controlled during all stages of production, being influenced by the quantity of yeast and sugars left in the bottled product, and also by the acidity of the mix. Prolonged fermentation causes the wine to turn into vinegar, and only special bottles of wine can be aged inside the bottle without becoming vinegar.
In all stages of wine making, tests are made to ensure that the chemicals inside the mix are what the recipe says they should be.
As with software production, unit tests represent a control mechanism verifying the quality of the final product. They are a very good control mechanism, because of their excellent defect detection. In the case of wine, unit tests would be a control of acidity inside the wine mix. As time goes by, any instrument becomes decalibrated, meaning it still indicates a value but it’s not the right value. If you are still reading off that instrument, you will fail; if you know it’s broken and ignore it, you will also fail.
Unit tests are decalibrated when either a) they always fail or b) they always pass. There’s a good chance that if your unit tests a) always fail you failed to update them at some point and got used to the idea that they’re wrong. At this point you can easily forget that you ever wrote them and mark the time spent making them in the same category you place the time you spend on feisbuc. If b) they always pass it means you are not writing enough unit tests or you have stopped writing them a long time ago; feisbuc time as well.
Please drink test responsibly!