Getting PHPUnit Working - Include Path not set correctly?

Jarrod Nettles picture Jarrod Nettles · Nov 3, 2010 · Viewed 56.4k times · Source

I'm trying to get PHPUnit working on my development environment but I've hit a bit of a roadblock when it comes to including PHPUnit in my scripts. I know that I need to set the include path on PHP but every combination I've tried fails without the compiler seeing the PHPUnit_Framework_TestCase class.

I just ran updates on PHP and PEAR and PHPUnit is installed on the computer because I can access it through the command line just fine.

PHPUnit is installed at /usr/share/php/PHPunit

Pear is at /usr/share/php/PEAR

Is there something I'm missing? This is my first time trying to use PHPUnit or even something from PEAR for that matter. I'm on Ubuntu 10.10. Any help would be appreciated.

Edit - There is nothing in the include path in my PHP ini. Right now the code is just

<?php
class Stacktest extends PHPUnit_Framework_TestCase
{

}

I have no idea what to include or what to set in the include path because it seems that for all the info on the web about PHPUnit, this little bit of information is critically absent.

Answer

xrstf picture xrstf · Jan 9, 2011

As of PHPUnit 3.5, you have to include the autoloader yourself:

require 'PHPUnit/Autoload.php'; // PEAR should be in your include_path