6

なぜこれが必要なのですか?私は symfony プロジェクトで (そして Zend fw を使用して) テストを実行しており、phpunit は影響を受けるすべてのファイルに対してクローバーを生成します。しかし、symfony と Zend ライブラリ (および他のすべてのサードパーティのもの) の報道を見たくありません。私のコードのみのカバレッジを参照してください。または、これはクローバービューアーを行うべきでしょうか? hudson の clover プラグインを使用していますが、特定のソースの表示をサポートしていません。clover プラグインは、私のコードが 20% しかカバーしていないことを示しています。これは、symfony と Zend ライブラリも考慮しているため、正しくありません。

ところで、これを取得する別の方法があるかもしれませんか?

4

2 に答える 2

10

phpunit の構成ファイルを作成する必要があります。その構成ファイル内で、特定のファイルまたはディレクトリをコード カバレッジから除外できます。

サンプル ファイルは次のようになります。

<phpunit stopOnFailure="false">
    <testsuite name="Name">
    </testsuite>

<filter>
    <whitelist>
            <directory suffix=".php">../php</directory>
            <exclude>
                    <file>../php/somefile.php</file>
                    <directory suffix=".php">../php/pdf</directory>
            </exclude>
    </whitelist>
</filter>

<logging>


        <log type="coverage-html" target="target-dir/coverage" charset="UTF-8" yui="true" highlight="true"/>
        <log type="coverage-clover" target="target-dir/build/logs/clover.xml"/>
</logging>

</phpunit>

上記のファイルでは、ファイル ../php/somefile.php と拡張子.ディレクトリからのphp ../php/pdf

このファイルに phpunit.xml という名前を付け、テストを実行するディレクトリと同じディレクトリに配置します。phpunit を実行すると、conf が取得されます。

この特定のファイル名を使用できない場合は、コマンド ラインから名前を指定できます。

phpunit --configuration yourconf.xml

phpunit 構成ファイルの詳細については、http://phpunit.de/manual/3.7/en/appendixes.configuration.html を参照してください

于 2010-09-07T17:14:00.537 に答える
0

構成 xml ファイルのフィルター ノートは、loggin ノードでラップする必要があると思います。

このような:

<phpunit stopOnFailure="false">
    <testsuite name="Name"></testsuite>

    <logging>
        <filter>
                <whitelist>
                        <directory suffix=".php">../php</directory>
                        <exclude>
                                <file>../php/somefile.php</file>
                                <directory suffix=".php">../php/pdf</directory>
                        </exclude>
                </whitelist>
        </filter>

        <log type="coverage-html" target="target-dir/coverage" charset="UTF-8" yui="true" highlight="true"/>
        <log type="coverage-clover" target="target-dir/build/logs/clover.xml"/>
    </logging>

于 2012-10-05T10:29:58.723 に答える