The missing link in Drupal: Code Coverage
Levi Govaerts - Capgemini
<?php
xdebug_start_code_coverage();
function a($a) {
echo $a * 2.5;
}
function b($count) {
for ($i = 0; $i < $count; $i++) {
a($i + 0.17);
}
}
b(6);
b(10);
var_dump(xdebug_get_code_coverage());
?>
array
'/home/httpd/docs/xdebug_get_code_coverage.php' =>
array
5 => int 1
6 => int 1
7 => int 1
9 => int 1
10 => int 1
11 => int 1
12 => int 1
13 => int 1
15 => int 1
16 => int 1
18 => int 1
1: this line was executed
-1: this line was not executed
-2: this line did not have executable code on it
phpcov is a command-line frontend for the PHP_CodeCoverage library.
But what if we need an analysis of multiple files?
PHPCOV
Merges all analysis results in to a datbase
Module A
Module B
Module C
Drupal modules integrate with Travis CI
Installs Drupal during Travis CI build
Executes both Simpletest & PHPUnit testcases
RawGit serves raw files directly from GitHub with proper Content-Type headers.
Create distribution
Deploy DrupalCoverage
Drupal Core coverage reports
Patch support
Custom module support
Integration with coveralls.io / drupal.org
Feedback
Development Support
BOF @ DrupalCon Dublin
Questions?