PHPUnit 3.5一直显示错误

时间:2012-02-16 21:34:26

标签: php unit-testing zend-framework phpunit

我想让phpunit 3.5正常工作。但每次我运行我的测试时都会收到此错误:

PHP Fatal error:  Class 'PHPUnit_Framework_TestFailure' not found in C:\wamp\bin
\php\php5.3.9\pear\PHPUnit\Framework\TestResult.php on line 266
PHP Stack trace:
PHP   1. {main}() C:\wamp\bin\php\php5.3.9\phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3.9\phpunit:49
PHP   3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.9\pear\PHPUnit\Tex
tUI\Command.php:129
PHP   4. PHPUnit_TextUI_TestRunner->doRun() C:\wamp\bin\php\php5.3.9\pear\PHPUni
t\TextUI\Command.php:188
PHP   5. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.3.9\pear\PHPUni
t\TextUI\TestRunner.php:305
PHP   6. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.3.9\pear\PHPUni
t\Framework\TestSuite.php:693
PHP   7. PHPUnit_Framework_TestSuite->runTest() C:\wamp\bin\php\php5.3.9\pear\PH
PUnit\Framework\TestSuite.php:733
PHP   8. PHPUnit_Framework_TestCase->run() C:\wamp\bin\php\php5.3.9\pear\PHPUnit
\Framework\TestSuite.php:757
PHP   9. PHPUnit_Framework_TestResult->run() C:\wamp\bin\php\php5.3.9\pear\PHPUn
it\Framework\TestCase.php:576
PHP  10. PHPUnit_Framework_TestResult->addError() C:\wamp\bin\php\php5.3.9\pear\
PHPUnit\Framework\TestResult.php:717

Fatal error: Class 'PHPUnit_Framework_TestFailure' not found in C:\wamp\bin\php\
php5.3.9\pear\PHPUnit\Framework\TestResult.php on line 266

Call Stack:
    0.0004     327336   1. {main}() C:\wamp\bin\php\php5.3.9\phpunit:0
    0.3024     699040   2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3
.9\phpunit:49
    0.3024     699392   3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.
9\pear\PHPUnit\TextUI\Command.php:129
    0.3929    3300128   4. PHPUnit_TextUI_TestRunner->doRun() C:\wamp\bin\php\ph
p5.3.9\pear\PHPUnit\TextUI\Command.php:188
    0.4153    3766872   5. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\ph
p5.3.9\pear\PHPUnit\TextUI\TestRunner.php:305
    0.4154    3767136   6. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\ph
p5.3.9\pear\PHPUnit\Framework\TestSuite.php:693
    0.4155    3767336   7. PHPUnit_Framework_TestSuite->runTest() C:\wamp\bin\ph
p\php5.3.9\pear\PHPUnit\Framework\TestSuite.php:733
    0.4155    3767336   8. PHPUnit_Framework_TestCase->run() C:\wamp\bin\php\php
5.3.9\pear\PHPUnit\Framework\TestSuite.php:757
    0.4158    3767336   9. PHPUnit_Framework_TestResult->run() C:\wamp\bin\php\p
hp5.3.9\pear\PHPUnit\Framework\TestCase.php:576
    0.4257    3934600  10. PHPUnit_Framework_TestResult->addError() C:\wamp\bin\
php\php5.3.9\pear\PHPUnit\Framework\TestResult.php:717


c:\wamp\www\ZendSkeletonApplication\module\page\test>

这是我的包含路径:

string(252) "C:\wamp\bin\php\php5.3.9\pear\PHPUnit\Autoload.php;C:\wamp\www\Zend
SkeletonApplication\module\page/test;C:\wamp\www\ZendSkeletonApplication\vendor\
ZendFramework\library;.;C:\wamp\bin\php\php5.3.9\pear;C:\pear\pear;C:\pear\pear;
C:\pear\pear;C:\pear\pear"

文件TestFailure doe存在。

所以任何想法都是?

2 个答案:

答案 0 :(得分:2)

您应该在路径中包含完整的PHPUNit目录,并且还必须手动包含自动加载器。所以在php文件的顶部添加:

require 'PHPUnit/Autoload.php'

在您的包含路径中,将PHPUnit部分更改为C:\wamp\bin\php\php5.3.9\pear\PHPUnit(而不是您目前拥有的C:\wamp\bin\php\php5.3.9\pear\PHPUnit\Autoload.php)。

答案 1 :(得分:0)

尝试手动加载,看起来这个旧版本是错误的

require_once 'PHPUnit/Framework/TestFailure.php';