Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

QaFoo.com:
Code Coverage with Behat
Apr 03, 2013 @ 17:37:30

On the QaFoo blog today there's a post for those using the Behat testing tool showing a way to collect code coverage metrics based on your tests using the PHP_CodeCoverage library and phpcov.

There is generally no point in having code coverage for Behat test cases because of their nature: The purpose of an acceptance test is to assert a certain behavior of an application, not to technically test a piece of code. Therefore, there is no point in checking for uncovered code pieces in order to write a Behat test for it. That said, there is still a scenario where you want to peek at code coverage of Behat tests: When creating them as wide-coverage tests before starting to refactor legacy code. Behat in combination with Mink provides you with a great tool for such tests.

They help you get the tools installed and show the code you'll need to add to the application itself to collect the coverage data as the tests execute. It keys off of a file existing/not existing to know if it should execute the coverage or not. The phpcov tool can then be used to generate the HTML output of the coverage information for easy viewing.

tagged: code coverage testing functional behat tutorial phpcov phpcodecoverage

Link: http://qafoo.com/blog/040_code_coverage_with_behat.html

Sebastian Bergmann's Blog:
Towards Better Code Coverage Metrics in the PHP World
Jun 20, 2011 @ 13:10:57

Sebastian Bergmann has a new post to his blog talking about some of the future plans for better code coverage metrics for PHP applications (not just the statistics that we have now as generated from PHPUnit runs combined with Code_Coverage PEAR package and Xdebug).

Xdebug currently only supports what is usually referred to as Line Coverage. This software metric measures whether each executable line was executed. Based on the line coverage information provided by Xdebug, PHP_CodeCoverage also calculates the Function / Method Coverage software metric that measures whether each function or method has been invoked.

The various kinds of coverage they're planning the in future include statement coverage, branch coverage (boolean evaluation), call coverage, path coverage with an alternative of linear code sequence and jump coverage (LCSAJ).

tagged: codecoverage metrics analyze code xdebug phpunit phpcodecoverage pear

Link:

Sebastian Bergmann's Blog:
Code Coverage Dashboard
Apr 05, 2010 @ 14:28:00

In a new post to his blog Sebastian Bergmann talks about a new "dashboard view" that's been added to work with the PHPUnit testing suite - PHP_CodeCoverage. He talks more about what it has to offer:

PHP_CodeCoverage is a library that provides collection, processing, and rendering functionality for PHP code coverage information. Its architecture has support for multiple backends for collecting code coverage information (currently only support for Xdebug is implemented) and for reporting code coverage information (for instance using Clover XML or as an HTML report).

The dashboard shows the code's class coverage distribution, class complexity, top project risks and the least tested methods to help you narrow down potential issues in your application. Here's an example of the output.

tagged: codecoverage phpunit phpcodecoverage dashboard

Link:


Trending Topics: