Remote Code Coverage

Browser tests are executed on different machine, then one, where code coverage information is collected (and tests are executed). To solve that problem this library uses remote coverage collection. Following steps needs to be performed before using this feature:

On Remote Server

This is web-server, where website used in tests is located.

  1. Install Xdebug PHP extension on web-server
  2. Copy library/aik099/PHPUnit/RemoteCoverage/RemoteCoverageTool.php into web-server’s DocumentRoot directory.
  3. Include following code before your application bootstraps:

require_once 'RemoteCoverageTool.php';

On Test Machine

This is machine, where PHPUnit tests are being executed.

Following code needs to be placed in the setUp method of the test case class (that extends BrowserTestCase class) to enable remote coverage information collection:


// "host" should be replaced with web server's url

How This Works

  1. each test sets a special cookie on website under test
  2. when cookie is present, then RemoteCoverageTool.php script collects coverage information and stores it on disk
  3. once test finishes, then http://host/?rct_mode=output url is accessed on remote server, which in turn returns collected coverage information
  4. remote coverage information is then joined with coverage information collected locally on test machine