CodeCoverage plug-in for debugging, testing and code reviews

The Plugin Gallery is a venue for users of PKP software to share their plugins.

Moderators: jmacgreg, michael, John

Forum rules
The Public Knowledge Project Support Forum is moving to

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.
Posts: 94
Joined: Sat May 16, 2009 2:45 pm

CodeCoverage plug-in for debugging, testing and code reviews

Postby jerico » Sat Nov 06, 2010 5:20 pm

Hi plugin gallery,

I've written a plug-in that can be used for debugging purposes. It uses PHPUnit's nice code coverage report to show which parts of the code have been used by a request (or several requests).

The installation requirements are: PHP 5, the xdebug extension and PHPUnit must be installed on the system.

You also have to configure the following parameters in your's [debug] section (please read first!):

1) PHPUnit's root directory:

Code: Select all

coverage_phpunit_dir = /path/to/phpunit/base/dir/

This directory must contain PHPUnit's Util and Runner directories.

2) A target directory for report output:

Code: Select all

coverage_report_dir = /path/to/report/output/directory/

This directory must be empty (!) and writable by the web server user. If you point to the wrong directory you'll have a lot to clean up later ;-) or you may even loose data because the plug-in will remove all files from that directory before generating a new report. So please be CAREFUL.

Please make sure that both paths end with a directory separator ('/' on *nix and '\' on Windows).

NB: Requests to this plugin and the generic plugin category overview page will not be analyzed.

The plugin can be installed both manually in OJS 2.3.3 and also automatically in the upcoming OJS 2.3.4. The lib-part goes to lib/pkp/plugins/generic! If you do a manual install you'll have to run the upgrade script before you can use the plug-in:

Code: Select all

php tools/upgrade.php upgrade

As soon as you've installed and enabled the plug-in you every request will be logged to the database.
You should usually have the plugin's management page open in a separate tab. There you can purge previous results or you can generate the coverage report. The report will be written to the configured report directory. You'll have to access the report directory either directly with your browser or configure your web server to serve it. Once you got the index page open the rest should be obvious.

This plugin should work in all current PKP applications, namely OJS, OCS, OHS and OMP.

Credits go to Sebastian Bergmann who wrote PHPUnit and the reporting extension that I'm using here.
CodeCoverage plug-in version 1.0.0
(6.82 KiB) Downloaded 193 times

Return to “Plugin Gallery”

Who is online

Users browsing this forum: No registered users and 3 guests