簡體   English   中英

PHPUnit代碼覆蓋率

[英]PHPUnit Code Coverage

我正在學習單元測試Zend Framework應用程序的繩索。 到目前為止,我已經設置了PHPUnit來與Zend Framework一起工作,並開始編寫一些簡單的測試用例。

我的問題是,我想知道為什么Code Coverage無法在我的phpunit.xml中的日志標記中phpunit.xml

我沒有收到任何錯誤但沒有生成覆蓋率報告。

但是當我運行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 Ba​​ker評論的問題。 我選擇這個,因為它來自一個小項目,非常簡單。

<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手冊中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM