LoginSignup
4
2

More than 5 years have passed since last update.

CircleCIでPHPUnitのコードカバレッジを出力する

Last updated at Posted at 2017-09-07

CircleCIでPHPUnitのコードカバレッジを表示します。

CircleCIには事前にxdebugが入っているので、xdebugのインストールについては何もしなくて良いです。

circle.ymlを以下のように設定してテスト実行時のコマンドを上書きします。

circle.yml
test:
  override:
    - ./vendor/bin/phpunit --coverage-html=$CIRCLE_ARTIFACTS

テスト対象はphpunit.xmlで設定します。

phpunit.xml
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="bootstrap/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    ---(中略)---
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
            <directory suffix=".php">./domain</directory>
            <directory suffix=".php">./infra</directory>
        </whitelist>
    </filter>
    ---(中略)---
</phpunit>

カバレッジの結果はArtifactsのタブから見ることができます。
スクリーンショット 2017-09-07 11.18.45.png

結果はこんな感じで表示されます。

スクリーンショット 2017-09-07 11.22.38.png

4
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2