PHPUnit. Error: No code coverage driver is available. (having xdebug installed)
PHPUnit. Error: No code coverage driver is available. (having xdebug installed)
类似问题的答案 有效,但我安装了 xdebug。
(如果这件事我正在使用:windows7、netbeans8.1、php7、wamp3)
在 Netbeans 中显示代码覆盖率导致:
Error: No code coverage driver is available
,
输出如下:
"C:\wamp\www\treningPHPUnitSymfony2.8\bin\phpunit.bat" "--colors"
"--log-junit" "C:\Users\chiny\AppData\Local\Temp\nb-phpunit-log.xml"
"--coverage-clover"
"C:\Users\chiny\AppData\Local\Temp\nb-phpunit-coverage.xml"
"C:\Program Files\NetBeans 8.1\php\phpunit\NetBeansSuite.php" "--"
"--run=C:\wamp\www\treningPHPUnitSymfony2.8\src\TreningBundle\Tests\Controller\RabarbarControllerTest.php"
PHPUnit 5.3.4 by Sebastian Bergmann and contributors.
Error: No code coverage driver is available
.II 3 /
3 (100%)
Time: 1.13 seconds, Memory: 4.00MB
OK, but incomplete, skipped, or risky tests! Tests: 3, Assertions: 1,
Incomplete: 2. Done.](url)
xdebug conf (C:\wamp\bin\apache\apache2.4.17\bin\php.ini):
[xdebug]
zend_extension ="C:/wamp/bin/php/php7.0.1/zend_ext/php_xdebug-2.4.0rc3-7.0-vc14.dll"
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="C:/wamp/tmp"
xdebug.show_local_vars=0
已加载扩展
(我在同一 Windows 分区中有 netbeans 和项目目录)
大多数 Apache/PHP 安装中有 2 个 php.ini
文件,在 WAMPServer
中肯定有
要修改 PHP 在 Apache 中使用的正确 php.ini
,请使用菜单
wampmanager->PHP->php.ini
但对于 PHP CLI 使用的 php.ini
文件,您必须手动编辑
\wamp\bin\php\php{version}\php.ini
如果在 CLI 中配置了 XDEBUG,php -v
的结果应该如下所示
php -v
PHP 7.0.6 (cli) (built: Apr 27 2016 14:00:40) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
注意
当前 WAMPServer 3 是 3.0.4
可以在 SourceForge
上找到 ADDON 升级
最新的 ADDON PHP 版本是 PHP7.0.6 也可以在 SourceForge 上获得
请参阅 The WampServer Forum 了解最新版本的 PHP / MYSQL / Apache ADDONS for WAMPServer 3
还有:
您可能会发现您必须 tweek the XDEBUG config parameters 在 php.ini
中满足您的特定需求
我在新安装 PHP 7.1 时遇到过这个问题,这就是我为解决问题所做的工作
$ brew install php71-xdebug
$ php -i | grep xdebug
// 检查是否安装了 xdebug
$ phpunit
之后就成功了。此外,这就是我的 phpunit.xml 看起来我需要将整个结构列入白名单的原因,因为它是共享组件
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Tests">
<directory suffix=".php">./Tests/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="./build/logs/clover.xml"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory>./</directory>
</whitelist>
</filter>
</phpunit>
此解决方案仅适用于 MacOS,如果你想让它在 Linux 上运行,那么你需要使用适用的包管理器,如 apt-get 等。
在 Debian 上有同样的问题:
Error: No code coverage driver is available
我通过安装 php-xdebug 修复了它:sudo apt install php-xdebug
类似问题的答案
(如果这件事我正在使用:windows7、netbeans8.1、php7、wamp3)
在 Netbeans 中显示代码覆盖率导致:
Error: No code coverage driver is available
, 输出如下:
"C:\wamp\www\treningPHPUnitSymfony2.8\bin\phpunit.bat" "--colors" "--log-junit" "C:\Users\chiny\AppData\Local\Temp\nb-phpunit-log.xml" "--coverage-clover" "C:\Users\chiny\AppData\Local\Temp\nb-phpunit-coverage.xml" "C:\Program Files\NetBeans 8.1\php\phpunit\NetBeansSuite.php" "--" "--run=C:\wamp\www\treningPHPUnitSymfony2.8\src\TreningBundle\Tests\Controller\RabarbarControllerTest.php" PHPUnit 5.3.4 by Sebastian Bergmann and contributors.
Error: No code coverage driver is available
.II 3 / 3 (100%)
Time: 1.13 seconds, Memory: 4.00MB
OK, but incomplete, skipped, or risky tests! Tests: 3, Assertions: 1, Incomplete: 2. Done.](url)
xdebug conf (C:\wamp\bin\apache\apache2.4.17\bin\php.ini):
[xdebug]
zend_extension ="C:/wamp/bin/php/php7.0.1/zend_ext/php_xdebug-2.4.0rc3-7.0-vc14.dll"
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="C:/wamp/tmp"
xdebug.show_local_vars=0
已加载扩展
(我在同一 Windows 分区中有 netbeans 和项目目录)
大多数 Apache/PHP 安装中有 2 个 php.ini
文件,在 WAMPServer
要修改 PHP 在 Apache 中使用的正确 php.ini
,请使用菜单
wampmanager->PHP->php.ini
但对于 PHP CLI 使用的 php.ini
文件,您必须手动编辑
\wamp\bin\php\php{version}\php.ini
如果在 CLI 中配置了 XDEBUG,php -v
的结果应该如下所示
php -v
PHP 7.0.6 (cli) (built: Apr 27 2016 14:00:40) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
注意
当前 WAMPServer 3 是 3.0.4
可以在 SourceForge
最新的 ADDON PHP 版本是 PHP7.0.6 也可以在 SourceForge 上获得
请参阅 The WampServer Forum 了解最新版本的 PHP / MYSQL / Apache ADDONS for WAMPServer 3
还有:
您可能会发现您必须 tweek the XDEBUG config parameters 在 php.ini
中满足您的特定需求
我在新安装 PHP 7.1 时遇到过这个问题,这就是我为解决问题所做的工作
$ brew install php71-xdebug
$ php -i | grep xdebug
// 检查是否安装了 xdebug
$ phpunit
之后就成功了。此外,这就是我的 phpunit.xml 看起来我需要将整个结构列入白名单的原因,因为它是共享组件
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Tests">
<directory suffix=".php">./Tests/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="./build/logs/clover.xml"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory>./</directory>
</whitelist>
</filter>
</phpunit>
此解决方案仅适用于 MacOS,如果你想让它在 Linux 上运行,那么你需要使用适用的包管理器,如 apt-get 等。
在 Debian 上有同样的问题:
Error: No code coverage driver is available
我通过安装 php-xdebug 修复了它:sudo apt install php-xdebug