Monday, September 10, 2007

Test-driven development for Hudson

Recently I convinced myself to implement the various features that I was missing in Hudson: cumulative notifications, build in the right order when commits span multiple projects, gracefully handle project deleted in SVN. But as it involved hacking the guts of Hudson and I didn't want to click-click the whole day in the configuration screens, I wrote the various usecases as tests. Up to now in Hudson, the only existing tests were true unit-tests in the sense of checking that an isolated method returns the proper result. But there was no test to actually verify the complete lifetime of a project: configure, build, delete, or to verify behavior with Subversion.

Writing integration tests for Hudson was hard, here are the ugly bits:

  • Subversion local repository is created with svnadmin create in a temporary directory

  • Actual builds are done with shell script, this will only work on *nix machines

  • There are various reflection hacks. The Hudson API could be more consistent in that area and allow to set field values programmatically


See for yourself and run mvn test in Hudson Tester. There's a long way to go to be able to
easily write tests for Hudson, but the proof of concept works. I hope
this test-driven approach can help Hudson developers implement new features more
efficiently and prevent regressions across releases.

No comments: