But when I finally gave it the old college try, I found that the AsUnit application was quite practical and sped up my workflow. The XUL UI automates some repetitive tasks of Test-Driven Development (TDD):
- Creating a new class: com.example.Widget
- Creating package folders as necessary: com and example
- Creating the unit test class: com.example.WidgetTest
- Creating AllTests suite classes in every package folder that contains unit tests
Practically, this means that when I need a new class, I fire up the AsUnit app, type in com.example.Widget, and in seconds I have code skeletons ready to go. It's so much easier to be disciplined about writing tests first when they exist right off the bat.
For more instructions, see this excellent AsUnit tutorial by Tim Beynart.
AsUnit for Windows
If this is at all convincing, you can download the AsUnit XUL UI Windows installer here. (This link is gone from asunit.org at the moment, while Luke Bayes is reorganizing the site.)
AsUnit for OS X
If you're on the Mac, you can download an AsUnit OS X installer provided by Aral Balkan. The build is a little out-of-date, missing a few minor features added since then. However, Aral graciously wrote out his steps for creating the app at the end of his post. Luke is into Git now, so the source for XUL UI is in github.
AsUnit for Vista: Problem and Solution
When I tried to install the AsUnit XUL UI on a Vista machine, the app refused to launch. It seemed as though Vista's increased security was causing problems with XULRunner. The best solution I found was by rhoq on the FlashDevelop boards. You simply create a shortcut to the .exe with the following in the target field:
"C:\Program Files\AsUnit\xulrunner\xulrunner.exe" -app ../xului/application.ini
My shortcut has this in the Start in field, which seems to be necessary:
Obviously, adjust these to your particular install path.
A Parting Thought
I do Test-Driven Development for many reasons, but mainly because it's fun. Writing tests first is 100 times more enjoyable than writing tests after production code. I'm not even joking when I say "it feels like rock climbing." I'll try to explain this in a later post.