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¶
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¶
tools:
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:
tools:
external_code_coverage:
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:
tools:
external_code_coverage:
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.
PHP¶
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
--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
.Python¶
pip install scrutinizer-ocular
ocular --access-token "your-token" --data-file ".coverage" --config-file ".coveragerc"
For more information, view the Python setup instructions.
Ruby¶
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'
Scrutinizer::Ocular.watch!
# ... further test-setup
Running tests:
SCRUTINIZER_ACCESS_TOKEN=your-token build exec rspec spec
For more information, view the Ruby setup instructions.