简体   繁体   English

PHPstorm PHPunit代码co覆盖

[英]PHPstorm PHPunit code co coverage

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中运行我的测试套件时,代码覆盖率为0%(我知道这不是真的),当我从命令行运行PHPunit时,记录的HTML输出文档显示我实际上已经覆盖了并列出所有详细信息。

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 ). 在PHPstorm中,我的PHP解释器设置为/ usr / local / bin / php(PHP 5.6.7)和xdebug 2.3.2(截图: https ://dl.dropboxusercontent.com/u/379071/Screen%20Shot% 202015-04-20%20at%206.57.39%20 PM.png )。 In my PHPunit preferences, I have the 'path to script' set to my composer autoload.php file. 在我的PHPunit首选项中,我将'path to script'设置为我的composer autoload.php文件。 In my runtime configuration, I have a PHPunit runtime set to run with a 'defined configuration file' (See below). 在我的运行时配置中,我将PHPunit运行时设置为使用“已定义的配置文件”运行(参见下文)。 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配置文件的内容:

<?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. 通过将项目根目录更改为绝对路径(/ media / hdd / ...),我能够解决问题。

Possible you just run tests without code coverage in phpstorm. 可能你只是在phpstorm中运行没有代码覆盖的测试。 You can invoke Run with coverage action. 您可以调用Run with coverage操作。 I have similar configurations and all works fine. 我有类似的配置,一切正常。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM