Writing unit tests = good.
JUnit = good.
However...
Writing unit tests ≠ fun,
especially when dealing with classes that need a lot of stuff to work.
This is especially annoying when you are trying to test a relatively simple class, but it operates on a complex (in terms of data) class. You have to go through a lot of crap just to create the data that your relatively simple class needs to demonstrate that it works properly. This is the difference between unit testing examples in a book and unit tests in the real world.
Enter EasyMock.
Now very mature and well-liked in the Java community, EasyMock creates mock objects automagically and lets you get back to worrying about the class you're actually trying to test. Bravo!
Not only does it take HUGE amounts of pain out of writing JUnit tests, but it also has one of the most beautiful DSL-style APIs I've ever used. When you use it, your code reads like English. It's just a real pleasure to use, and thanks to the gorgeous API, the learning curve is very short.
I think every JUnit test I have written without EasyMock has shortened my life span.
Use EasyMock = Live Longer
No comments:
Post a Comment