One of the refreshing changes in my new job is that one of the large core pieces of our system is very easy to JUnit test. I hate that unit tests can't be brought to bear on more kinds of problems, but when they can, boy it is satisfying.
Today, for example, in order to fix a frustrating bug I had to learn how to use JavaCC grammars for the first time. Powerful it may be, but if you're trying to understand machine-generated code with variables named "jj_la1_0", it's difficult to feel confident monkeying with a grammar. Hard to know what's going on, very easy to screw something up. JUnit to the rescue. This is one of the situations where I actually do test-driven development--- I pre-write tests that start out green to prove that I didn't break the system. And then I pre-write even more tests that start out red to prove that my fix isn't working yet. And then I keep tinkering until they're all green. But there's an arguably even greater benefit of JUnit than the red/green: you can run in a cleanroom environment. That means:
|