This post originated from an RSS feed registered with Java Buzz
by dion.
Original Post: RE: JUnit, Test your behavior not methods
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
KT has written about JUnit, Test your behavior not methods.
I definitely feel this one. It seems that there is a flow of cause and effects that we run into in our world:
Someone comes up with a good idea
The idea is spread
The idea gets tweaked along the way
Mass adopters follow the letter of the warped idea, and not the thought behind it
When I look at that flow, I could be talking about a lot of things. For example, Religion :)
Where does this fit into unit testing?
Well, the idea of doing unit tests is obviously a good one. Test Driven Development is also a great tool that we can use to get good designs, and less bugs.
However, it has somehow been warped in many dev shops. In these shops they take the LETTER of the idea "build unit tests == good" and focus on making as many unit tests as possible. Their code coverage tool helps make a game out of this. "I have got 80% coverage".
However, who gives a monkeys about your coverage compared to the QUALITY of your damn tests. It is easy to use a tool, or manually, create tests for every method and branch, but most of the tests are crap!
I would rather have less coverage (and at areas where I think I really need them) which have really smart tests of behaviour (not just passing nulls and seeing what happens).