External Code Coverage

If you are already using an external service for continuous integration and would just like to use Scrutinizer's first class code review tools, you can also send us code coverage that was generated by an external service.


Configuration is a two step process. First, you need to tell Scrutinizer that you send code coverage information from an external service in your build config. Second, you also need to configure your external service to send the code coverage information to Scrutinizer.

Changes in Scrutinizer Configuration

    external_code_coverage: true

Defining Timeout

By default, Scrutinizer will wait 5 minutes for the code coverage information to arrive. If your test-suite runs longer than that, you can change the timeout:

        timeout: 600    # Timeout in seconds.

Merging Coverage Data

If you have split your tests across multiple runs, Scrutinizer also supports merging your test data, just set the runs option:

        runs: 2    # Scrutinizer will wait for two code coverage submissions

Changes in Third-Party Configuration

In addition to modifying your Scrutinizer configuration, you also need to change the build configuration of your external service to generate code coverage and then upload that code coverage information to Scrutinizer.

Tip: Make sure to always run the upload command even if your tests failed. In the latter case, the inspection will automatically be canceled on Scrutinizer.


vendor/bin/phpunit --coverage-clover=coverage.clover
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --access-token="your-token" --format=php-clover coverage.clover
Note: If you have a public repository, you can omit the --access-token option. For private repositories, you can generate an access token on your profile page (https://scrutinizer-ci.com/profile/applications) - make sure to create it with READ access only. Furthermore you can add repository and revision parameters such as --repository=gp/my-project-repository and --revision=1a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16pq.


pip install scrutinizer-ocular
ocular --access-token "your-token" --data-file ".coverage" --config-file ".coveragerc"

For more information, view the Python setup instructions.


Set-up the scrutinizer-ocular gem:

gem install scrutinizer-ocular
# At the very top of spec_helper.rb, test_helper.rb or equivalent
require 'scrutinizer/ocular'

# ... further test-setup

Running tests:

SCRUTINIZER_ACCESS_TOKEN=your-token build exec rspec spec
Tip: The access token is only required for private repositories. Do not add it for public repositories.

For more information, view the Ruby setup instructions.