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のタブから見ることができます。
結果はこんな感じで表示されます。
