Author image
Senior Developer

Hudson and Simpletest

We've recently set up a Hudson Continuous Integration build server to help us with testing our sites. We got selenium up and running fairly quickly, it installs and tests all the sites and Hudson has aplugin to report the results from selenium tests. But we also wanted to run simpletests and report those results too. This article explains how I've set it up on our server, and will hopefully give you a head start on the way to getting it set up on yours. The problem: 1. Run simpletests from the command line. 2. Integrate the results with the Hudson's interface.

#1 Is actually fairly easy to do, recent versions of Drupal's simpletest come with a backport of the script that can run tests from the command line, however, getting the results from the script into a format that Hudson will understand is a bit more challenging. Since Hudson started out as a Java build tool, it can natively understand the JUnit test result format. Now, I had hoped that it would be really easy to ask the script to output in a format other than it's default, stdout. It turns out that simpletest does have a plugable reporting mechanism, but it also turns out that relying on an external library was too good for Drupal, and the simpletest Drupal uses is a hack. So I decided to hack the script to output the results in the format I wanted.

To cut a long story short, it's really hard to find a specification of the JUnit output file format, but after lots of trying, I had a script that could run simpletests and report the results in a JUnit friendly (Hudson friendly) format, yey!

Find the script attached, there's an extra argument from the normal set, --xml which allows you to specify the directory in which to output the xml result files. Lovely.

Finally you'll want to make a bash script that passes in all the right arguments to the script and then run that from Hudson, as part of the normal build process.

Edit: We lost the attachment in a server migration, but actually this in Drupal 7 core anyway!


Good job.

I was working with this script and ran into some issues with it using Simpletest 6.x-2.10. I updated the script today to work this version. There were some function name mismatches for simpletest_get_all_test() vs. simpletest_tests_get_all()).

You can see the updated script at:

This is great! We had to jump the same hurdle in creating our Hudson CI environment for The Economist, though your additions to run-tests implement some nice features (like helptext) we never got around to. ;)

We will be demonstrating our results in Paris. Maybe see you there? Hudson BoF?

Either way, I think CI for Drupal is gong to be huge, and figuring out how to take advantage of tools like Hudson rather than re-inventing the wheel would be great. (e.g. if Drupal used phpunit, the above script wouldn't be necessary...)

Anyway, excellent work, and thanks for sharing your great script!

Hi, will this script work with SimpleTest and D6?

That's exactly what it was written to work with, so, yes!

Hi, so I've got this setup mostly implemented. Thanks for the tips. One last piece I need to figure out. So Hudson is pulling my source code from Git into its workspace. When I run what url do i point it at so that it has access to the drupal instance?


You'll need to get a web server set up to serve files from the workspace or copy them over to a web root elsewhere.

Comments on this article are now closed, if you want to give us feeback you can use our contact form instead.