加入收藏 | 设为首页 | 会员中心 | 我要投稿 莱芜站长网 (https://www.0634zz.com/)- 云连接、建站、智能边缘云、设备管理、大数据!
当前位置: 首页 > 编程开发 > PHP > 正文

PHPUnit代码覆盖

发布时间:2020-07-24 00:33:56 所属栏目:PHP 来源:互联网
导读:我正在使用单元测试Zend Framework应用程序学习绳索.到目前为止,我已经设置了 PHPUnit来使用Zend Framework,并开始编写一些简单的测试用例. 我的问题是,我想知道为什么Code Coverage不能在phpunit.xml中的logging标签中设置. 我没有收到任何错误,但没有生成覆

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

我的问题是,我想知道为什么Code Coverage不能在phpunit.xml中的logging标签中设置.

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

但是,当我运行phpunit –coverage< dir>

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

<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>

有人遇到过吗?那可能是什么问题?

这是我的一个项目的phpunit.xml,这很好.您可以看到,记录部分在过滤器部分之外,所以这可能是由Mark Baker评论的问题.我选择了这个,因为它是从一个小项目,非常简单.
<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.

(编辑:莱芜站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读