首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHPUnit代码覆盖率

PHPUnit代码覆盖率
EN

Stack Overflow用户
提问于 2012-04-24 00:37:41
回答 1查看 18K关注 0票数 13

我正在学习单元测试Zend Framework应用程序的诀窍。到目前为止,我已经设置了使用Zend FrameworkPHPUnit,并开始编写一些简单的测试用例。

我的问题是,我想知道为什么尽管在我的phpunit.xml中设置了logging标签,Code Coverage仍然不能工作。

我没有收到任何错误,但没有生成覆盖率报告。

但是,当我运行phpunit --coverage <dir>时,它可以正常工作

我的phpunit的日志记录部分如下:

代码语言:javascript
复制
<phpunit bootstrap="./application/bootstrap.php" colors="true">
        <testsuite name="CI Test Suite">
            <directory>./</directory>
        </testsuite>
        <testsuite name="Library Test Suite">
            <directory>./library</directory>
        </testsuite>

        <filter>
            <whitelist>
                <directory suffix=".php">../application/</directory>
                <exclude>
                    <directory suffix=".phtml">../application</directory>
                    <file>../application/Bootstrap.php</file>
                    <file>../application/controllers/ErrorController.php</file>
                </exclude>
            </whitelist>
           <logging>
               <log type="coverage-html" target="./log/report" charset="UTF-8" yui="true"
   highlight="true" lowUpperBound="50" highLowerBound="80" />
               <log type="testdox" target="./log/testdox.html" />    
           </logging>
        </filter>
    </phpunit>

以前有没有人遇到过这种情况?那么可能的问题是什么呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-24 02:42:02

这是我的一个项目的phpunit.xml,运行良好。正如您所看到的,日志记录部分位于过滤器部分之外,因此这可能是Mark Baker所评论的问题。我选择了这个,因为它来自一个小项目,而且非常简单。

代码语言:javascript
复制
<phpunit bootstrap="./bootstrap.php" colors="false">
    <testsuite name="HSSTests">
        <directory>./</directory>
    </testsuite>

    <filter>
        <whitelist>
            <directory suffix=".php">d:/wamp/app_hss/</directory>
            <exclude>
                <directory suffix=".phtml">d:/wamp/app_hss/</directory>
                <directory suffix=".php">d:/wamp/app_hss/tests/</directory>
            </exclude>
        </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>

您可能需要的所有信息都在PHPunit manual中。

票数 27
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10284592

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档