Unit testing with NetBeans and phpUnit

Huzzah! I have found a way of being able to run the Unit tests in NetBeans.

Since phpUnit is essentially a set of php scripts itself, I thought to myself there must be a way of invoking it.

What I did was setup a source file as the boostrap for the Test Runner, set this file as NetBeans index file and from there you can just run it and see the test results in the output window or debug and it step into the test you are interested in.

It is not a fantastic solution but it is definately a stop gap until they do implement php Unit testing.

Heres my boostrap file for running tests:

$args = array(

$_SERVER['argv'] = $args;
$_SERVER['argc'] = count($args);

require_once 'PHPUnit/TextUI/Command.php';

// Exclude this file from code coverage


Its very simple, what I am doing is hard coding my arguments into the server environment variable (you could use the arguments in the NetBeans configuration) which is where phpUnit gets the arguments from.
Including the phpUnit TestUI test runner which has the main entry point, excluding this file from code coverage and then I just sit back and l let phpUnit run its course.

This is only a work around until Netbeans supports phpUnit.