微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/php/131252.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐