Incremental Testing

One Button Testimonial

We're a group of confirmed Emacs addicts working on a 130 KLOC Java project (about half those LOCs are unit tests) using 'make' as the build tool. We're very happy with this toolset and wouldn't trade it for anything. Anybody who has worked in this kind of environment knows that it's a simple matter to compile and test your code - no more than three or four keystrokes to change to the right buffer, compile, and run the entire test suite.

As the project has grown, though, the test suite has gotten bigger and slower. Despite lots of effort towards speeding it up, the ~7000 tests take about four minutes to run if you run them all. So our modified version of JUnit, and our Makefiles, and our project conventions, work together to let you easily run just the tests for one class, or one package, or one module. Until today, this has involved typing the class name and part of the package name for the class you want to test, maybe 20 or 30 keystrokes. total.

This is sufficiently inconvenient that the typical coding cycle became code, compile, code, compile, code, compile, test one class, code, compile, code, compile, code, compile, run the whole test suite. You'd go several minutes between testing the class being modified, and perhaps twenty or more minutes between running the whole suite. Obviously, this isn't ideal, but it sounds so wimpy to say that twenty or thirty keystrokes was too much work and was impacting our process, that we just let things be.

Today I was inspired by the "OneButtonTesting" thread to write an Emacs macro which figures out the appropriate class and package name, computes (by our convention) the name of the corresponding test class, figures out (by our convention, again) where the build directory is, and then runs the tests for that one class.

Now when you're editing a class, you can press ONE KEY and run the tests for that individual class. The cycle immediately changed to code, test one class, code, test one class, code, test everything. The feeling of boosted confidence and increased velocity was tangible.

So if you're like us, and you're telling yourself, "We don't have OneButtonTesting, but we don't really need it," you're just wrong. It really makes a difference. Do yourself a favor and set it up.

-- ErnestFriedmanHill?

From the XpMailingList.

View edit of January 1, 2009 or FindPage with title or text search