Debugging Unit Tests ?

It might sound trivial and the solution is more than easy - but as I am frequently asked how todo this, here is the simple answer.

Create a PHP file in the directory where you start your Unittests usually with this content:

1
2
3
4
5
6
7
8
9
10
11
12
13
 
$unitTest = '...Your Unittest name - e.g. unit_mytest.php or Alltests.php etc...';
 
$_SERVER['argv'] = array(
'/...path to your PHPUnit.../PHPUnit/TextUI/Command.php',
$unitTest
);
 
echo "<pre>";
include( '/...path to your PHPUnit.../PHPUnit/TextUI/Command.php' );
echo "</pre>";
 
...

Point your browser to this file, et voila - Unit test in the Browser.

Ok ;) - this solution is very easy and silly - but it works very well. And at least I got the impression that there are enough people around who do not know how to debug unit tests…

Comments

One Response to “Debugging Unit Tests ?”

  1. Tomas Liubinas on December 20th, 2007 10:36 am

    Thanks for the hint ;)

Leave a Reply