phpunit抛出未捕获的异常’PHPUnit_Framework_Exception

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了phpunit抛出未捕获的异常’PHPUnit_Framework_Exception脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个Zend Framework项目,并希望使用单元测试来测试它.

tests文件夹中,我有PHPunIT.XMl如下;

<PHPunit bootstrap="./application/bootstrap.PHP" colors="true">
<testsuite name="Application Test Suite">
    <directory>./</directory>
</testsuite>

<filter>
    <whitelist>
        <directory suffix=".PHP">../application/</directory>
        <exclude>
            <directory suffix=".phtML">../application/</directory>
            <file>../application/Bootstrap.PHP</file>
            <file>../application/controllers/ErrorController.PHP</file>
        </exclude>
    </whitelist>
</filter>

<LOGging>
    <log tyPE="coverage-html" target="./log/rePRot" charset="UTP-8"
    yui="true" highlight = "true" lowUpoerBound="50" highLowerBound="80"/>
    <log type="textdox" target="./log/testdox.html" />
</logging>

我在/ tests / application文件夹中有bootstrap.PHP,如下所示:

<?PHP
error_reporting(E_ALL | E_STRICT);

// define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH',realpath(dirname(__FILE__) . '/../../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV',(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR,array(
    realpath(APPLICATION_PATH . '/../library'),get_include_path(),)));

require_once 'Zend/Loader/Autoloader.PHP';

require_once 'controllers/ControllerTestCase.PHP';
Zend_Loader_Autoloader::getInstance();

当我转到命令行时,运行以下命令

PHPunit --configuration PHPunit.xml

它抛出异常:

PHP Fatal error:  Uncaught exception 'PHPUnit_Framework_Exception' with message
'Neither "Application Test Suite.PHP" nor "Application Test Suite.PHP" Could be
opened.' in D:\PHP\PHP5\PEAR\PHPUnit\Util\Skeleton\Test.PHP:102
Stack trace:
#0 D:\PHP\PHP5\PEAR\PHPUnit\TextUI\Command.PHP(157): PHPUnit_Util_Skeleton_Test-
>__construct('Application Tes...','')
#1 D:\PHP\PHP5\PEAR\PHPUnit\TextUI\Command.PHP(129): PHPUnit_TextUI_Command->run
(Array,true)
#2 D:\PHP\PHP5\PHPunit(53): PHPUnit_TextUI_Command::main()
#3 {main}
  thrown in D:\PHP\PHP5\PEAR\PHPUnit\Util\Skeleton\Test.PHP on line 102

我该怎么办呢?

您会注意到它抛出异常,因为它查找的文件名与您为测试套件提供的名称相同.您需要实际编写测试套件,然后将该测试套件的名称提供给您的配置: http://www.phpunit.de/manual/3.2/en/organizing-test-suites.html

脚本宝典总结

以上是脚本宝典为你收集整理的phpunit抛出未捕获的异常’PHPUnit_Framework_Exception全部内容,希望文章能够帮你解决phpunit抛出未捕获的异常’PHPUnit_Framework_Exception所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。