【问题标题】:PHPUnit 3.5 keeps showing errorsPHPUnit 3.5 不断显示错误
【发布时间】:2012-03-08 07:59:02
【问题描述】:

我正在尝试让 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 文件确实存在。

有什么想法吗?

【问题讨论】:

    标签: php unit-testing zend-framework phpunit


    【解决方案1】:

    您应该在路径中包含完整的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)。

    【讨论】:

      【解决方案2】:

      尝试手动加载,好像这个旧版本有问题

      require_once 'PHPUnit/Framework/TestFailure.php';
      

      【讨论】:

        猜你喜欢
        • 2020-03-23
        • 2011-01-28
        • 1970-01-01
        • 1970-01-01
        • 2019-07-19
        • 2011-10-02
        • 1970-01-01
        • 2021-01-29
        • 1970-01-01
        相关资源
        最近更新 更多