Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code Coverage tools for PHP [closed]

Is there any code coverage tool available for PHP? I wish to check the code coverage of my code and API's written in PHP, but have not been able to lay my hands on any code coverage tool for PHP, as it is more of a server side language and dynamic in nature.

Does anyone know of a method by which code coverage for PHP can be executed?

like image 926
gagneet Avatar asked Dec 08 '08 07:12

gagneet


People also ask

What is PHP code coverage?

In computer science, code coverage is a measure used to describe the degree to which the source code of a program is tested by a particular test suite. A program with high code coverage has been more thoroughly tested and has a lower chance of containing software bugs than a program with low code coverage.

Which tool is used for code coverage?

Code coverage tools are available for many programming languages and as part of many popular QA tools. They are integrated with build tools like Ant, Maven, and Gradle, with CI tools like Jenkins, project management tools like Jira, and a host of other tools that make up the software development toolset.

How do I check my code coverage?

To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.

How does code coverage tool work?

Code coverage tools use static instrumentation in which statements monitoring code execution are inserted at critical junctures in the code. Now, adding instrumentation code does result in increased execution time and code length.


2 Answers

xdebug has Code Coverage Analysis.

Check this chapter of the PHPUnit Manual

like image 163
Christian C. Salvadó Avatar answered Sep 21 '22 08:09

Christian C. Salvadó


See our PHP Test Coverage tool from Semantic Designs:

http://www.semanticdesigns.com/Products/TestCoverage/PHPTestCoverage.html

Very low overhead, handles huge systems of files, intuitive GUI showing coverage on specific files, and generated report with coverage breakdown at method, class and package levels.

Best of all, no requirement to install anything in the system being tested. No need for xdebug, etc., which means you don't have to argue with the sysadmin to do your testing.

You can use it with PHPUnit to get unit-test driven coverage. Or you can use it on your website to collect coverage from any functional testing approach/tools you may have.

like image 36
Ira Baxter Avatar answered Sep 22 '22 08:09

Ira Baxter