已安装PHPUnit但未找到类PHPUnit_TestCase

时间:2010-04-19 21:27:16

标签: php unit-testing macos phpunit osx-snow-leopard

谈论落在第一道障碍。我的测试脚本:

<?php

require_once('PHPUnit/Framework.php');

class TransferResponseTest extends PHPUnit_TestCase {

    ...

}

运行我的测试用例:

$ phpunit TransferResponseTest

Fatal error: Class 'PHPUnit_TestCase' not found in 
/Volumes/Data/greg/code/syndicate/tests/TransferResponseTest.php on line 5
$ php -i | grep include_path
include_path => .:/usr/lib/php => .:/usr/lib/php
$ ls -l /usr/lib/php/PHPUnit/
total 8
drwxr-xr-x  16 root  wheel   544 27 Mar 19:03 Extensions
drwxr-xr-x  28 root  wheel   952 27 Mar 19:03 Framework
-rw-r--r--   1 root  wheel  3193 27 Mar 19:03 Framework.php
drwxr-xr-x   8 root  wheel   272 27 Mar 19:03 Runner
drwxr-xr-x   5 root  wheel   170 27 Mar 19:03 TextUI
drwxr-xr-x  32 root  wheel  1088 27 Mar 19:03 Util

我已将/etc/php.ini-default复制到/etc/php.ini,并明确将包含路径指定为/usr/lib/php/,结尾为/,但仍未成功。

$ php -i | grep include_path
include_path => .:/usr/lib/php/ => .:/usr/lib/php/
$ phpunit TransferResponseTest.php 
PHP Fatal error:  Class 'PHPUnit_TestCase' not found in 
/Volumes/Data/greg/code/syndicate/tests/TransferResponseTest.php on line 5
$ phpunit --version
PHPUnit 3.4.11 by Sebastian Bergmann.

有什么想法吗?

1 个答案:

答案 0 :(得分:6)

不是PHPUnit_TestCase,而是PHPUnit_Framework_TestCase。并且您不必要求在运行测试时已经由PHPUnit加载的“PHPUnit / Framework.php”。