Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Back to:
www.javaworld.com/javaworld/jw-08-2008/jw-08-unit-testing-doomed.html.
I must admit I wasn't always using unit testing so I guess I was also contributing to these trends. But a couple of years ago, I sat down and did it. It took a short amount of time to get used to using it all the time.
Now I don't think I could live without jUnit. My projects contain hundreds of jUnit test cases and they run all the time. Many times jUnit test cases precede the actual class or classes that they are meant to test. That is I code with test cases my expected outcome and then work on the code to make it happen. Lately when designing new APIs, I write mock-up unit test cases, create dummy classes and interfaces to see how a particular concept might look from the user's perspective. Once something looks good or promising, then take the next step of actual design behind the scenes how to implement it. If all still looks good at stage 2 then its on to implementation. All the while jUnit test cases, broken up into small test cases, test progressively more advanced and complex features.
Then there is the, checking the obvious stuff. How many times have I implemented test cases for rudimentary and simple stuff that even I myself have said, that will never break, or its impossible for it to break, to only find out months later that I did something to break even the seemingly unbreakable piece of code. jUnit keeps me in check, on my toes and fully satisfied with immediate feedback.
Lastly, I can see huge difference in the way my code looks now when compared to code I wrote a few years ago.
I completely agree with your assessment of benefits. I proved it on my own skin.