0
votes

Isn't PHPUnit supposed to require the class itself using the naming conventiong "ClassTest"?

  • I have a php file "Router.php" with a class Router
  • My PHPUnit testing class is defined as following:

    class RouterTest extends PHPUnit_Framework_TestCase

However it raises a fatal error for file not found "Router.php". If I require it manually everything is ok.

What's wrong with it?

1
Are you using a framework? Your framework should automatically include Router.php, if you aren't then you have to include itWe0
Which directory is RouterTest.php in, which is Router.php, and which directory do you run phpunit from?Darren Cook

1 Answers

1
votes

There is nothing wrong with it. How would PHPUnit know where your classes are in relation from the tests?

For your tests, you need to either require the class under test yourself or create an autoloader that will require the class for you. PHPUnit has no idea where it should be getting the files from. It has an autoloader for its internal files but that is it.