30 May 2012
Today, I made public a whole bunch of commits I made while improving the Code coverage project for use with ReviewDriven. You may remember the screenshot I included in Part 2: Breathing new life into the testbot which is where this is coming from. Thanks to the improvements the module now actually works and is much more efficient, polished, accurate, and much more. With that in mind I am proud to announce the first stable release of the project targeted at Drupal 7.14.
Using the module you can get coverage reports for individual page executions or any combination of tests. Code coverage reports can be extremely useful in determining areas of code that are not tested at all or provide a snapshot of the code involved in generating a page.
Pages
Code coverage can be recorded by adding ?code_coverage=true
to the end of a page URL. After the page has completed execution a linked will be placed at the bottom of the HTML which will display outside the page style.
The link will open the coverage report generated for that page request. The report will include all the files that where loaded during the execution of the page.
Tests
Similarly, a link is provided for the code coverage recorded during a test run.
Reports
The report includes two parts: 1) the summary or index, and 2) the line-by-line coverage information. The links described above point to the summary of the coverage information.
The links in the summary point to the line-by-line coverage information overlayed on the corresponding code. The colors indicate the following.
- green = executed
- red = not executed
- gray = ignored (or non-executable)
Filters
The coverage scope may be filtered to focus on improving coverage for a particular module/file/directory. Reducing the scope will also improve the coverage recording performance which may be useful when when dealing with large tests.
Future
I have already integrated the Code coverage project with Conduit (the open source ReviewDriven platform) which will be replacing the current system running qa.drupal.org. The plan is to get the new platform up and running in parallel with the current system at which time regular coverage runs against core (and contrib projects) can be made publicly available.
Comments
Unit Tests, Functional Tests or both?
Chris Weber (not verified) 6 years ago
Awesome! I love metrics like this. I'd like to write tests so that we can get to 100% code coverage. But I'm wondering what that tasks would look like. Does this measure how well the code is covered by Unit Tests, Functional Tests, or both?
Measures coverage for both
boombatower 6 years ago
Code coverage works for both unit and functional tests.
so what's the coverage?
dalin (not verified) 6 years ago
So the big question then is - what's the code coverage for all core tests?
B.T.W. I can't subscribe to get the answer because there's no email field, hence notification throws a validation error.
Awesome, can't wait
cam8001 (not verified) 6 years ago
It will be great to have highly visible tools tand metrics that let contributors know how much of Drupal code is covered. Can't wait!
Add new comment