Type: New Feature
Affects Version/s: 2.0
Fix Version/s: 2.0
Right now we are using simpletest to perform both general unittesting and functional db unit testing.
While it works great, it's difficult to know what is being already tested and what's missing. When I was working in
MDL-19057 was really difficult to know what's missing in those tests. So we need some sort of (basic) code coverage utility integrated within unit tests.
Unlucky it seems that simpletest is missing such feature(is planned for the future - 1.9, but far away, while others implement it pretty well (supporting file/class/method coverage analysis, annotations and a bunch of cool features). So we need to implement that ourselves.
To achieve that we are going to use Spike PHPCoverage http://developer.spikesource.com/projects/phpcoverage that provides basic file (not class/function) coverage analysis and reporting, it's simple and easily extensible.
So this improvement will include:
1) Add Spike PHPCoverage (0.82) to HEAD.
2) Extend current simpletest classes in order to support code coverage (just AutoGroup must be changed). Will support:
2.1) Execution with code coverage disabled / enabled.
2.2) Execution with internal code coverage support / external coverage support.
2.3) Introspection in tests to determine what files must be included/excluded in code coverage (this can be achieved by using some static variables in class or by annotations).
2.4) Add manually files to be included/excluded (apart from previous point).
2.5) Automatic detection of requirements (xdebug and some PEAR/XML libraries).
2.6) Easy migration from current tests to use the new extended classes.
3) Extend spikephpcoverage in order to:
3.1) Support multiple start_coverage/end_coverage sessions (instrumentations) in the same request. Required by db tests.
3.2) Ability to merge and report coverage information about those instrumentations together.
3.3) Store static reports in moodledata/codecoverage/admin/report/xxxx (unittest|dbtest)
3.4) Shot coverage summary inline in tests page
3.5) Use dirroot relative paths
4) Provide one coveragefile.php script to navigate / serve the static reports.
5) Protect everything with 'moodle/site:config'
6) Document usage in Moodle Docs: Requirements, enabling/disabling code coverage, internal / external code coverage, reports
That's all. Ciao
|Covered lines always show 1 usage||Closed|