I typically work with CruiseControl for PHP testing (using CC's Phing support, not phpundercontrol). I have only worked with Hudson a little, but have gotten Hudson to successfully record phpunit tests using phing's phpunit support.
The following instructions assume that you will be using Phing (not Ant) to manage your PHP project builds and that you have the necessary prereqs installed. It also assumes you have PHPUnit 3 installed (though PHPUnit 2.x should work too).
Step 1: Setup Project for Phing/PHPUnit
First you need to make sure that your project is testable using Phing. Here's a sample Phing build.xml that runs unit tests and creates a JUnit-compatible XML output.
<?xml version="1.0" ?>
<project name="Test Project" default="test">
<property name="tests.dir" value="." />
<property name="reports.dir" value="${tests.dir}/reports" />
<target name="test" description="Run PHPUnit tests">
<phpunit haltonerror="true" haltonfailure="true" printsummary="true">
<batchtest>
<fileset dir="${tests.dir}">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter type="plain" usefile="false" />
<formatter type="xml" usefile="true" todir="${reports.dir}" outfile="test-results.xml" />
</phpunit>
</target>
</project>
Step 2: Setup Hudson
- Install the Phing plugin for Hudson. Note that you may need to install Phing as a standalone pacakge (I put it in /opt/phing-2.3.3) and configure PHING_HOME in Hudson config to point to that directory. You should also be able to use the PEAR-installed Phing; however, I have not tested that.
- Configure Hudson to build your project using Phing.
- Configure Hudson to collect JUnit tests from your project. The name of our results file will be test-results.xml. In the example above you'd configure it to collect files from reports/*.xml.
Step 3: Build!
That should do it. Try building your project now. Hopefully it will collect the results.
Also see this Phing presentation, or this Phing presentation for more on Phing and (to a lesser extent) PHPUnit integration.
Good luck!