Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?