I have introduced PHP code coverage capability without spikephpcoverage.
There are the php_coverage module and the patch for the simpletest module.

Comments

vladimir.dolgopolov’s picture

StatusFileSize
new75.95 KB
new47.55 KB

Instruction:
0) enable xdebug php extension.
1) enable php_coverage module from php_coverage.zip. It's without comments, sorry.
2) edit this lines in php_coverage.module:

define('PHP_CODE_COVERAGE_SETTINGS_FILE', '/tmp/coverage_settings');
define('PHP_CODE_COVERAGE_DATA_FILE', '/tmp/coverage_data');

There should be absolute paths.
This files are created automatically and they don't need after running tests.
This files hold settings and a coverage data between subrequests.

3) edit setings in admin/settings/testing. Set 'Include paths' and 'Exclude paths' as you wish. One path for one line, relative to the Drupal root.
4) apply the patch php_coverage.patch
5) go to admin/build/testing (Testing) and run one test (Block functionality eg.)
6) go to admin/build/testing/coverage (Coverage report).

Here you can see a list of covered files (coverage_report.png).

If you click a file you'll see a code coverage report for the file (coverage_file.png).

Advantages:
1) this code coverage handles subrequests' coverages like $this->drupalPost();
2) a highlight php code capability
3) this is not depended on external stuff

vladimir.dolgopolov’s picture

Title: Code coverage reporting (via xdebug) » Code coverage without spikephpcoverage (big screenshots)
Project: Drupal core » SimpleTest
Version: 7.x-dev »
Component: simpletest.module » Miscellaneous
Status: Needs work » Active
StatusFileSize
new886.29 KB
new62.29 KB
new91.14 KB
new96.6 KB

There are fullsize screenshots so you can see it.

  • p1_settings.png - settings for the code coverage.
  • p2_test_list.png - "testing" menu with 2 tabs
  • p3_report.png - a list of covered files after "Block functionality" tests.
  • p4_file.png - coverage details for "modules/block/block.module" file.
vladimir.dolgopolov’s picture

Status: Active » Needs review

It seems I should change "status".

gábor hojtsy’s picture

So you intend to have this submodule as part of the Drupal 7 distribution itself? Would it be still possible to just release it as a contributed module if it is not found suitable for Drupal 7 core?

dries’s picture

Vladimir, in Drupal we don't capitalize each word in a sentence such as a title. We write "PHP code coverage", not "PHP Code Coverage". See the coding standards. There are violations of this in nearly all screenshots. It should be easy to fix though.

dries’s picture

Status: Needs review » Needs work

Also, the patch for Simpletest needs code comments.

Otherwise looks exciting! :)

dries’s picture

Simpletest is now part of Drupal core so you might want to change the project from 'SimpleTest' to 'Drupal'.

boombatower’s picture

Project: SimpleTest » Drupal core
Version: » 7.x-dev
Component: Miscellaneous » simpletest.module

Moving.

boombatower’s picture

What are the status of these two attempts in relation to each other.

http://drupal.org/node/252292

catch’s picture

Title: Code coverage without spikephpcoverage » Code coverage reporting (via xdebug)

This looks really, really nice. Subscribing so I can test when it's back to CNR.

vladimir.dolgopolov’s picture

Title: Code coverage without spikephpcoverage (big screenshots) » Code coverage reporting (via xdebug)
Project: SimpleTest » Drupal core
Version: » 7.x-dev
Component: Miscellaneous » simpletest.module
Status: Active » Needs review
StatusFileSize
new19.97 KB

Thanks to all for the interest and advice.

I've merged the simpletest module and the previous stuff.
Let's look how it works now.

Now if you have XDebug enabled then there are 2 tabs: "Test lists" and "Coverage report".
You can now make XDebug code coverage setup in admin/settings/testing.
Added comments, some UI tuning.
Updated screenshots in http://drupal.org/node/260032#comment-849004.

By default the code coverage disabled.

The "Instruction" from http://drupal.org/node/260032#comment-848868 is almost needless.

catch’s picture

cwgordon's got a module using a similar approach at http://drupal.org/project/code_coverage - it'd be good to have this in testing.module though.

cwgordon7’s picture

I actually disagree - I think it belongs in a separate module, and thus can continue to live there. If there's one thing we actually would need testing.module for, it's re-introducing hook_simpletest(now hook_testing) to act before and after tests.

moshe weitzman’s picture

Nice work. I'd also like to see an independant module that may or may not be distributed with simpletest. Code coverage is useful outside of simpletest actually. We should be able to do a code coverage report on any page, not just simpletest. This is very important when tuning the bootstrap and thinning our modules to take advantage of code registry.

boombatower’s picture

Status: Needs review » Fixed

This has been completed using module and #14 has separate issue #287264: Remove simpletest dependancy

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

cloudbull’s picture

Hi there, how's going with this php_coverage finally ???
Where does it go ??

Keith