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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Not a bug
    • 2.6
    • None
    • Unit tests
    • None
    • 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

            skodak Petr Skoda
            dobedobedoh Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: