State of the Unittests

2434027498_cd2c94d79b

Perhaps the biggest drawback of unittests is that they require quite some maintenance. Even if the code being tested does not change, the environment in which unittests are run changes, thus making some unittests to fail. At Zemanta, we have made a particularly poor job at mocking outside services and therefore the state of our unittests is degrading even faster than the industry average. To alleviate this problem and to push programmers to fix failing unittests, I'm conducting a monthly check of unittests in all our projects. I've started to do this check in June last year, but only this month all tests in all the projects pass (Actually, one test was still failing but I decided to just fix this test myself). The major benefit of having all tests passing is that programmer does not have to think or bug coworkers with questions. When you checkout the latest code and the tests are failing, you know the problem is in your environment and not in the code. When you refactor some code and the tests are failing, you know it's your changes that have caused the tests to fail. Unittests are perhaps the most important tool how to make long term support of software tractable. I hope we will be keeping this tool of ours sharp.

Enhanced by Zemanta