PHPUnit代码覆盖率报告生成失败

时间:2010-06-28 09:52:31

标签: php code-coverage phpunit

我正在尝试PHPUnit的一些所谓好的功能,但我无法生成一个奇怪的代码覆盖率报告。我得到的是:

rolf@dev ~/projects/current/tests $ scripts/phpunit --configuration $PROJECTS/current/tests/conf/inc/tests.xml
[...]
Generating code coverage report, this may take a moment.
[...]
Fatal error: require_once(): Failed opening required 'lib/DataSource.php' (include_path=':::') in path/to/lib/WS/DataParser.php on line 10

但是,在这个类中,定义了一个特定的包含路径,并且在启动应用程序时,require_once的工作方式就像一个魅力。

可能是PHPUnit无法解决包含路径吗?

提前致谢并且累积了很长时间!

Rolf

2 个答案:

答案 0 :(得分:1)

如果您使用的是最新的PHPUNIT(3.5+),可能是因为Sebastion已经开始在程序中使用自动加载器。

你必须添加一行

 spl_autoload_register('__autoload');

在创建/包含/需要__autoload()函数后

因此,例如,具有我的自动加载器的文件称为函数。在我的引导程序中,我执行以下操作:

require_once(ROOT_PATH.'/lib/utils/functions.php');
spl_autoload_register('__autoload');

答案 1 :(得分:0)

您是否在任何测试/代码中更改了include_path?因为它看起来很奇怪(:::)

相关问题