Nothing can replace good development, and a good unit testing is a part of good development. I will not go as far as recommending hardcore test-driven development, but robust unit testing never hurts.
Pre-JUnit, having a "main" method in every Java class to be tested was the way I went about testing. In came web applications and testing this way suddenly felt difficult. Then a combination of JUnit, JMock and Spring enabled me to test my code more meaningfully. For multi-threaded systems where even debugging into the running code is virtually impossible and Unit testing can help only so much, intelligent use of logging can help a lot to both verify functionality and spot potential bugs.
Change is our constant friend, and unit tests enable your team to keep track of their key assumptions and all the parts of the code affected by any change in the code. Barring this, the team will inevitably waste time due to avoidable, simple bugs. This makes more sense as a company cannot be sure about who will change the code in future. Documentation, code-comments and well-written code can help a new developer to understand many things, but none of them can replace well-thought unit tests that capture the essential purpose, assumptions and functionality of the class in a very practical way. It also helps the developer to think about his code more deliberately and deeply. Overall, this adds to efficiency gains in terms of product development speed and code quality.
No comments:
Post a Comment