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

Additional unit test classes in a single test class are never tested

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Not a bug
    • Affects Version/s: 2.6
    • Fix Version/s: None
    • Component/s: Unit tests
    • Labels:
      None
    • Affected Branches:
      MOODLE_26_STABLE

      Description

      Noticed whilst writing some additional tests for backup/util/dbops/tests/dbops_test.php

      There are two classes in dbops_test.php, each with valid test cases.
      Running vendor/bin/phpunit in a variety of ways only tests the first class, and not subsequent classes.

      Specify by file:

      vendor/bin/phpunit backup/util/dbops/tests/dbops_test.php
      

      Edit phpunit.xml and remove all testsuites. Add the following instead:

          <testsuites>
              <testsuite name="core_backup">
                <directory suffix="_test.php">backup/util/dbops</directory>
              </testsuite>
       
          </testsuites>
      

      Now run:

      vendor/bin/phpunit --testsuite core_backup
      

      Or even:

      vendor/bin/phpunit
      

      You'll notice that each of these only runs a single test, with 19 assertions. None of the tests in the second class are tested at all.

      This also happens for lib/tests/pagelib_test.php. I suspect that there are other places where multiple tests exist in the same file, but I've not tested.

        Attachments

          Activity

            People

            Assignee:
            skodak Petr Skoda
            Reporter:
            dobedobedoh Andrew Nicols
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: