The missing link in Drupal: Code Coverage

Levi Govaerts - Capgemini

Resources

@legovaer

  • User Dashboard Module
  • Drupal Symfony Inject Module
  • Validators Module
  • Drupal CI
  • Scheduler Module (Port to D8)

Code Coverage

<?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

Code Coverage

PHPCOV

phpcov is a command-line frontend for the PHP_CodeCoverage library.

But what if we need an analysis of multiple files?

Code Coverage

PHPCOV-RUNNER

Code Coverage

PHPCOV-RUNNER

PHPCOV

Merges all analysis results in to a datbase

Travis CI

Drupal TI

Drupal TI

Module A

Module B

Module C

Drupal modules integrate with Travis CI

Drupal TI

Installs Drupal during Travis CI build

Drupal TI

Executes both Simpletest & PHPUnit testcases

GitHub

RawGit serves raw files directly from GitHub with proper Content-Type headers.

Now

here

is

a surprise

Drupal Coverage

 publishes Code Coverage reports to                via       by executing       commands

using

I know, right?

Example in the wild!

Roadmap

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?

Made with Slides.com