Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Code Block
    [pcov]
    extension=pcov.so
    pcov.enabled=1
    pcov.exclude='~(vendor|tests|node_modules|.git|client|.scannerwork)~'
    pcov.initial.memory=1073741824
    pcov.initial.files=30000
  2. Generate the code coverage

    Code Block
    cd /path/to/code
    XDEBUG_MODE=off php -d pcov.directory=`pwd` vendor/bin/phpunit --filter=totara_core --coverage-html /var/www/html/coverage_report

PHPStorm and XDebug/pcov

PHPStorm has the ability to run code coverage anaylsis in product using XDebug or pcov. The analysis is automatically loaded into the platform and displayed both in the Coverage tool, and in-editor when looking at files. Their documentation on code coverage explains how to set it up.

A few pointers and tips to help however:

  • You still need to define a whitelist

  • As a product we support several different versions of PHP - if you're using php-fpm and have them installed you can configure PHPStorm so that you can choose which version you run tests and coverage on

  • When looking at a testcase file you can click on the little arrows next to test case classes and test case methods and choose to run specific tests

Further reading