phpunit throws Uncaught exception #39;PHPUnit_Framework_Exception(phpunit 抛出未捕获的异常PHPUnit_Framework_Exception)
问题描述
我有一个 Zend Framework 项目,想用单元测试来测试它.
I have a Zend Framework project, and want to using unit testing to test it.
在测试文件夹中,我有 phpunit.xml
如下;
In tests folder, I have the phpunit.xml
as following;
<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
如下:
And I have bootstrap.php
in /tests/application folder as follows:
<?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();
当我转到命令行时,运行以下命令
when I go to the command line, run the following command
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
我该如何解决?
推荐答案
您会注意到它抛出了异常,因为它正在寻找与您为测试套件提供的 name
同名的文件.您需要实际编写一个测试套件,然后将该测试套件的名称提供给您的配置:http://www.phpunit.de/manual/3.2/en/organizing-test-suites.html
Youll notice its throwing the exception because its looking for a file named the same as the name
you provided for your test suite. You need to actually write a test suite and then supply the name of that test suite to your config: http://www.phpunit.de/manual/3.2/en/organizing-test-suites.html
这篇关于phpunit 抛出未捕获的异常'PHPUnit_Framework_Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:phpunit 抛出未捕获的异常'PHPUnit_Framework_Exception
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01