Remote code collection in PHP

In our project, we run PHPUnit tests that use Selenium and Curl to open pages on another development server. Server B has an Apache server serving the website. Server A starts the test task by synchronizing ( Rsync ) the project files to the development server B, therefore the project files are identical on both servers.

What are the options for remote collection of code coverage statistics in PHP?

We already use Xdebug to collect code coverage on unit tests that are run locally on server A (PHPunit directly uses project files and therefore start / stop collecting code coverage reports )

Update:

On server B, the website is displayed by a PHP instance running Apache. During lunch tests using Selenium / Curl, the PHP instance on server A uses the command line version. This instance cannot profile the PHP instance that Apache runs on server B.

When performing unit tests (without using another server and without using Selenium / Curl), we use the following command:

phpunit --coverage-html ./results/codecoverage/ ATestFile.php 

This generates a code coverage report for the test in "ATestFile.php" using Xdebug in PHP Cli.

+6
source share
2 answers

The PHPUnit-Selenium project on Github has a solution for this, and I believe that the old version built into PHPUnit 3.5 had the same thing. There are files in the PHPUnit_Extension_Selenium_TestCase folder that are used to capture code coverage information on server B. You need to configure Apache to add and add two PHP scripts - aptly named prepend.php and append.php - for each request.

For instructions, see the PHPUnit section of the Selenium documentation . Find "append".

+3
source

The OP requested alternatives that can generate reports from server B.

Our PHP Test Validation Tool collects test coverage data that is completely independent of PHPUnit (use it or not, as you see fit) and / or XDebug (does not use XDebug at all).

This means that you can use your code in any way that you think is useful (including external requests from server A) and get code coverage data.

You can request a snapshot of the protected code at any time. This display engine for the test coverage tool converts this snapshot into a visible display of the coverage superimposed on the source code and / or creates a final report.

+1
source

Source: https://habr.com/ru/post/902284/


All Articles