PHPstorm PHPunit代码合作覆盖 [英] PHPstorm PHPunit code co coverage

查看:83
本文介绍了PHPstorm PHPunit代码合作覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在PHPstorm中运行测试套件时,所有代码的覆盖率都返回0%(我知道这是不正确的),而当我从命令行运行PHPunit时,记录的HTML输出文档显示我实际上一定要覆盖并列出所有详细信息.

When I run my test suite in PHPstorm, the code coverage comes back with 0% for everything (which I know is not true), and when I run PHPunit from the command line, the logged HTML output documents show that I actually DO have coverage and lists all the detailed information.

在PHPstorm中,我将我的PHP解释器设置为/usr/local/bin/php(PHP 5.6.7)和xdebug 2.3.2(屏幕截图:

In PHPstorm, I have my PHP interpreter set to /usr/local/bin/php (PHP 5.6.7) and xdebug 2.3.2 (screenshot: https://dl.dropboxusercontent.com/u/379071/Screen%20Shot%202015-04-20%20at%206.57.39%20PM.png). In my PHPunit preferences, I have the 'path to script' set to my composer autoload.php file. In my runtime configuration, I have a PHPunit runtime set to run with a 'defined configuration file' (See below). When I run, all the tests run and pass (a failure shows a stack trace), but the code coverage is completely zero for everything.

任何帮助将不胜感激.我确定我只是错过了一些东西.

Any help would be greatly appreciated. I'm sure I've just missed something.

我的XML配置文件的内容:

Contents of my XML configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
         colors="true">
    <testsuites>
        <testsuite>
            <directory>tests</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist>
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
    <logging>
        <log type="coverage-html" target="./log/codeCoverage" charset="UTF-8"
             yui="true" highlight="true"
             lowUpperBound="50" highLowerBound="80"/>
        <log type="testdox-html" target="./log/testdox.html"/>
    </logging>
</phpunit>

推荐答案

我知道这是一个旧线程,但我刚遇到此问题.在我的情况下,项目路径包含指向其他hd的符号链接.通过将项目根目录更改为绝对路径(/media/hdd/...),我得以解决该问题.

I know this is an old thread but I just encountered this issue. In my case the project path contained a symlink to a different hd. By changing the project root to the absolute path (/media/hdd/...) I was able to resolve the problem.

这篇关于PHPstorm PHPunit代码合作覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆