Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-19579

Add support to analyse code coverage in unit testing

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Libraries, Unit tests
    • Labels:
      None

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stronk7 Eloy Lafuente (stronk7)
                Reporter:
                stronk7 Eloy Lafuente (stronk7)
                Tester:
                Andrew Davis
                Participants:
                Component watchers:
                Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  24/Nov/10