Here's my configuration for remote codecoverage with Codeception (Project on GitHub).
Steps for running up remote codecoverage collection
1. Make sure that xdebug installed and enabled.
2. Configure codeception.
File codeception.yml
(GitHub):
coverage:
enabled: true
c3_url: 'http://%SERVICE_HOST%/index-test.php/'
include:
- web/*
- config/*
- src/*
3. Enable coverage for the suits you need.
File acceptance.suite.yml
(GitHub):
coverage:
remote: true
In my example its enabled only for acceptance tests.
4. Include c3.php
file in your application bootstrap.
Application bootstrap file index-test.php
(GitHub):
// Start the remote code coverage collection.
require_once __DIR__.'/../c3.php';
// autoloader, application running and etc
// ...
5. Run coverage.
$ vendor/bin/codecept run --coverage --coverage-html
By default you can find your reports in tests/_output
directory.
Possible issues
1. Output directory not writable (tests/_output
).
$ chmod 777 tests/_output
2. Remote codecoverage not printed in console.
It should not be printed. From documentation:
coverage:
remote: true
In this case remote Code Coverage results won’t be merged with local ones, if this option is enabled. Merging is possible only in case a remote and local files have the same path. But in case of running tests on a remote server we are not sure of it.
3. Some other error.
Try to enable debug. If debug enabled, you can get your report or clear it.
curl -o codecoverage.tar "http://localhost:8080/index-test.php/c3/report/html"
End
Sometimes it's not a trivial task. So I hope this will help!