Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-56503 Improve the experience for running phpunit with coverage with phpdbg on php7
  3. MDL-65130

Improve coverage generation by only respecting the @covers annotation

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7
    • Fix Version/s: 3.7
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide

      Helpful hints:

      1. For xdebug, ensure you have the xdebug extension installed and enabled, the run phpunit:

        ./vendor/bin/phpunit --coverage-html coverage --testsuite mod_forum_testsuite
        

      2. The code coverage is located in the coverage folder of your moodle installation.
      1. Run phpunit with coverage generation for each of the following testsuites:
        1. core_privacy_testsuite
        2. mod_forum_testsuite
        3. core_files_testsuite
      2. Confirm that the generated coverage was more targeted

      Note: There are two ways of generating coverage:

      1. using xdebug
      2. using phpdbg

      The phpdbg version is much faster but there is a file leak which you will need to patch. I've recompiled my PHP to not suffer the bug:

      Show
      Helpful hints: For xdebug, ensure you have the xdebug extension installed and enabled, the run phpunit: ./vendor/bin/phpunit --coverage-html coverage --testsuite mod_forum_testsuite The code coverage is located in the coverage folder of your moodle installation. Run phpunit with coverage generation for each of the following testsuites: core_privacy_testsuite mod_forum_testsuite core_files_testsuite Confirm that the generated coverage was more targeted Note: There are two ways of generating coverage: using xdebug using phpdbg The phpdbg version is much faster but there is a file leak which you will need to patch. I've recompiled my PHP to not suffer the bug: 7.2+: https://github.com/php/php-src/pull/3965 7.1: https://github.com/php/php-src/pull/3968
    • Affected Branches:
      MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull Master Branch:
      MDL-65130-master

      Description

      From https://phpunit.readthedocs.io/en/8.0/configuration.html:

      forceCoversAnnotation

      Code Coverage will only be recorded for tests that use the @covers annotation documented in @covers.

      This will mean that only functions which are actually intended to be covered will be covered, rather than those which are included inadvertently.

        Attachments

        1. coverage_files_after.zip
          4.65 MB
        2. coverage_files_before.zip
          4.98 MB
        3. coverage_forum_after.zip
          4.64 MB
        4. coverage_forum_before.zip
          6.66 MB
        5. coverage_privacy_after.zip
          4.66 MB
        6. coverage_privacy_before.zip
          6.46 MB
        7. files-before-after.png
          files-before-after.png
          113 kB
        8. forum-before-after.png
          forum-before-after.png
          115 kB
        9. privacy-before-after.png
          privacy-before-after.png
          115 kB

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  20/May/19

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 4 hours, 15 minutes
                  1d 4h 15m