In API repo I have added codeception+c3
"require-dev": {
"codeception/codeception": "2.*",
"codeception/c3": "2.*",
I've also included c3.php inside index.php, but when trying to test it with --coverage I have this error
[PHPUnit_Framework_Exception] file_get_contents(http://local.api.codeception.com/c3/report/clear): fai led to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error
Is there ANY online example of remote codecoverage with Codeception?
Codeception is very flexible framework that you can use to write your Selenium tests.
Codeception is a multi-featured testing framework for PHP. It can handle unit, functional, and acceptance testing of web applications and it's powered by the already very popular PHPUnit testing framework.
Here's my configuration for remote codecoverage with Codeception (Project on GitHub).
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.
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"
Sometimes it's not a trivial task. So I hope this will help!
Ok, it was a configuration nightmare, but I've fixed it
Here is example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With