4

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

keeg
  • 3,990
  • 8
  • 49
  • 97
  • 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 Jun 05 '11 at 08:29
  • 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 Jun 09 '11 at 21:25

3 Answers3

13

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

jovani
  • 669
  • 8
  • 16
0

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
Asaph
  • 159,146
  • 25
  • 197
  • 199
  • Thanks, although that might work it's not the preferred solution as I would need to repeat these steps for each testcase. I have had this setup on a remote server and working properly without having to use include-path. I must be missing something else... – keeg Jun 06 '11 at 19:10
  • 1
    @keeg: As @David Harkness mentioned in his comment, the `include_path` may also be set in a boostrap file. Without you posting your code in the question, it's difficult for us to diagnose the issue for you. Another wild guess just based on experience with PHP on OSX: Is it a case-sensitivity issue? OSX filenames are case-insensitive which is forgiving when you `include`/`require` files. Then when you move to a case-sensitive platform, your code may break. – Asaph Jun 06 '11 at 19:17
0

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/

Deepak Lamichhane
  • 19,076
  • 4
  • 30
  • 42