...
Install pcov:
Code Block pecl install pcov
Note the generated path to
pcov.so
, e.g.,/usr/local/lib/php/extensions/no-debug-non-zts-20230831/pcov.so
.Update
php.ini
. Note here also that we update thememory_limit
to 8G:Code Block language ini memory_limit=8G [pcov] extension="path/to/pcov.so" pcov.enabled=1 pcov.exclude='~(vendor|tests|node_modules|.git|client|.scannerwork)~' pcov.initial.memory=1073741824 pcov.initial.files=30000
Generate the report:
Code Block phpunit --coverage-html /var/www/html/coverage_report /path/to/plugin/to/test
Viewing the report
...
using Totara docker developer environment
If using our Totara Docker Development environment - /wiki/spaces/IN/pages/108151852 - you can replace the output path for the coverage report /var/www/html/coverage_report
with /var/www/totara/src/coverage_report
. Once you’ve done this, execute the following steps to make it accessible:
...