Using PHPUnit2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


For the last couple of days I've been trying to get PHPUnit2 (the one
from Pear) working on my system.

I have read the documentation over and over but still can't get any
tests to run. I've created the following trivial piece of testcode and
put it in TrueTest.php. When I try to run 'phpunit TrueTest' nothing
happens, the same with 'phpunit TrueTest.php' and 'phpunit TrueTest
TrueTest.php'. If I run phpunit without arguments I get the expected
help information. What am I missing?


require_once 'PHPUnit2/Framework/TestCase.php';
require_once 'controller/frontcontroller.php';

class TrueTest extends PHPUnit2_Framework_TestCase {

  public function __construct($string) {

  public function testTrue() {


$suite = new PHPUnit2_Framework_TestSuite('TrueTest');
$result = $suite->run();


Med venlig hilsen
- Jacob Atzen

Re: Using PHPUnit2

Quoted text here. Click to load it

Apparently I was missing some undocumented use patterns. For future
reference it's easier to use the --skeleton on an existing class.
Something along the lines of 'phpunit --skeleton [classname]'.

- Jacob Atzen

Re: Using PHPUnit2

Jacob Atzen wrote:

Quoted text here. Click to load it
Do you mean you got it working? If you don't, you could try pnt/unit,
(It is undocumeted, included in the framework download, but you do not
need the framework to run it (would'nt be of much use for testing the
framework it errors in the framework could break the unit testing tool ;-)


Henk Verhoeven.

Re: Using PHPUnit2

Quoted text here. Click to load it

Yes, I finally managed to run some tests with PHPUnit2.

- Jacob Atzen

Site Timeline