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

Remove forceCoversAnnotation

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.7.1, 3.8
    • Fix Version/s: 3.7.3
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide
      1. Drop the attached coverage.php into grade/grading/form/rubric/tests
      2. Copy it to grade/grading/form/guide/tests
      3. Re-init phpunit:

        php admin/tool/phpunit/cli/init.php
        php admin/tool/phpunit/cli/util.php --buildcomponentconfigs=true
        

      4. Run phpunit on a single testsuite with coverage:

        phpdbg -qrr ./vendor/bin/phpunit --testsuite gradingform_guide_testsuite --coverage-html=coverage
        

      5. Open the generated coverage/index.html file
      6. Navigate to grade/grading/form/guide within it
        1. Confirm that there was coverage generated
      7. Remove the coverage directory
      8. Run phpunit using the gradingform_rubric configuration file with coverage:

        phpdbg -qrr ./vendor/bin/phpunit -c grade/grading/form/rubric --coverage-html=coverage
        

      9. Open the generated coverage/index.html file
      10. Navigate to grade/grading/form/rubric within it
        1. Confirm that there was coverage generated
      Show
      Drop the attached coverage.php into grade/grading/form/rubric/tests Copy it to grade/grading/form/guide/tests Re-init phpunit: php admin/tool/phpunit/cli/init.php php admin/tool/phpunit/cli/util.php --buildcomponentconfigs=true Run phpunit on a single testsuite with coverage: phpdbg -qrr ./vendor/bin/phpunit --testsuite gradingform_guide_testsuite --coverage-html=coverage Open the generated coverage/index.html file Navigate to grade/grading/form/guide within it Confirm that there was coverage generated Remove the coverage directory Run phpunit using the gradingform_rubric configuration file with coverage: phpdbg -qrr ./vendor/bin/phpunit -c grade/grading/form/rubric --coverage-html=coverage Open the generated coverage/index.html file Navigate to grade/grading/form/rubric within it Confirm that there was coverage generated
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull Master Branch:
      MDL-66011-master

      Description

      We initially introduced this partially because of a bug in phpunit, partially a bug in php, and partially incorrect documentation in the phpunit docs. All of these things have been fixed.

      In addition to that, PHPUnit will be removing the @covers::<!public> annotation and friends in PHPUnit 10 (only @covers::functionName will continue to work) and I/we don't think that it makes a huge amount of sense to cover private/protected functions as they are implementation specific parts of an API when it's not really the tests business as to how the implementation achieves the result.

      So: Let us remove the forceCoversAnnotation.

      We can continue to add @covers::functionName annotations if we desire because they still have a value in that you can add --strict-covers to the CLI which can be helpful when writing tests.

        Attachments

        1. coverage.php
          1 kB
        2. coverage.php
          2 kB
        3. screenshot-1.png
          screenshot-1.png
          95 kB

          Activity

            People

            Assignee:
            dobedobedoh Andrew Nicols
            Reporter:
            dobedobedoh Andrew Nicols
            Peer reviewer:
            Carlos Escobedo
            Integrator:
            Adrian Greeve
            Tester:
            Janelle Barcega
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Nov/19

                Time Tracking

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