4
votes

Just trying to run a simple test on my local box but i get the following error:

PHP Fatal error:  Class 'CTestCase' not found in ....

when running

$ phpunit UserTest

I guess my configuration must be missing something? I just can't figure out what.

Using:

OSX 10.6.7

PHP 5.3.4

PHPUnit 3.5.13

Yii 1.1.7

3
Please post the code of your test case so we have a hope of helping you. As Asaph said, make sure your include path is setup correctly either via the command line or a bootstrap.php file.David Harkness
Yes thank you! I had to point PHPUnit to the phpunit.xml file contained in the testing directory to map all the Yii classes. The xml file points to the bootstrap.php so all is good!keeg

3 Answers

13
votes

Make sure you run phpunit at the same directory where your phpunit.xml is. :)

0
votes

The error message is telling you that the class CTestCase cannot be located. PHPUnit accepts an --include-path option on the command line. You could try something like this:

$ phpunit --include-path .:/path/to/dir/containing/CTestCase UserTest
0
votes

I found the solution for me. But i am not sure whether this works for you all or not.

Here is the url for the solution

http://www.yiiframework.com/forum/index.php/topic/4728-running-unit-tests-on-windows-problem/