OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



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
If you post a plugin here, please include information on which versions of which applications it is compatible with. Attach a tarball of the plugin (e.g. tar cvzf myPlugin-0.1.tar.gz plugins/generic/myPlugin). Thanks for contributing!

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 config.inc.php'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


Usage:
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.
Attachments
codeCoverage-1.0.0.tar.gz
CodeCoverage plug-in version 1.0.0
(6.82 KiB) Downloaded 145 times
jerico
 
Posts: 94
Joined: Sat May 16, 2009 2:45 pm

Return to Plugin Gallery

Who is online

Users browsing this forum: No registered users and 3 guests