沃梦达 / 编程问答 / php问题 / 正文

PHPstorm PHPunit 代码共同覆盖

PHPstorm PHPunit code co coverage(PHPstorm PHPunit 代码共同覆盖)

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

问题描述

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.

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.

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>

解决方案

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 代码共同覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:PHPstorm PHPunit 代码共同覆盖

基础教程推荐