加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

phpunit抛出未捕获的异常’PHPUnit_Framework_Exception

发布时间:2020-12-13 13:14:05 所属栏目:PHP教程 来源:网络整理
导读:我有一个Zend Framework项目,并希望使用单元测试来测试它. 在tests文件夹中,我有phpunit.xml如下; phpunit bootstrap="./application/bootstrap.php" colors="true"testsuite name="Application Test Suite" directory.//directory/testsuitefilter whitelis
我有一个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:PHPphp5PEARPHPUnitUtilSkeletonTest.php:102
Stack trace:
#0 D:PHPphp5PEARPHPUnitTextUICommand.php(157): PHPUnit_Util_Skeleton_Test-
>__construct('Application Tes...','')
#1 D:PHPphp5PEARPHPUnitTextUICommand.php(129): PHPUnit_TextUI_Command->run
(Array,true)
#2 D:PHPphp5phpunit(53): PHPUnit_TextUI_Command::main()
#3 {main}
  thrown in D:PHPphp5PEARPHPUnitUtilSkeletonTest.php on line 102

我该怎么办呢?

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读