
Testing Tool
June 25, 2008It’s been long time since I disagree at the benefit of Testing framework or Testing tool at a level of individual class. It seems that people like to develop test classes for each class they build. Does it really incease quality of the actual classes? I honestly think that it won’t be worth while and wasting of time. Usually, those test classes are built by developers who build the actual classes, right? It seems to me it is a self-satisfaction but prove less or cost performance is not so great.
On the other hand, I agree at building scenario based test cases, which would be more realistic and cost-effective, and it most of the time makes sense because scenario is developed by functional people who may be close to the end customers or users.
I just don’t feel good whenever I read articles or books that mention where developers describe test classes for each class without thinking about its true value.
In some cases I agree – I have seen test cases that are *so* specific, they start testing implementation details rather than an interface or behavioral contract.
However, once you have a good body of unit tests, refactoring becomes much easier. In fact, it is pretty pain-free. I worked on a code base that desperately needed to refactor, but the tech lead would not allow it because he was too afraid of breaking the code. Now I work on a project with 500+ unit tests, and we can be much more sure that a refactor was successful if the unit tests also run.
I read a good article recently comparing test practices among Ruby and Java developers. It was saying how most Ruby shops require 100% test coverage, but most Java shops don’t. It makes sense, because Java has a lot of invisible code paths, like unchecked exceptions, that make 100% coverage pretty much impossible. I share your disdain for unit testing among people who insist that even plain getters/setters must be tested. But now that I’ve worked with it extensively, I certainly am much more in favor of it than I used to be.
Yeah, I agree at using test classes for refactoring project. It is pretty good idea for refactoring project. What I think now is that instead of blindly creating test classes for any classes, create test classes for critical or important classes would be effective and increase the quality of software without wasting time. Thank you, Greg.