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

Should be harder to write fragile unit tests that make unwarranted assumptions about a new Moodle install

    XMLWordPrintable

Details

    • MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE

    Description

      This is a similar in philosophy to -MDL-43835- which was done in Moodle 2.8. There, we randomised the starting value of DB sequences, to ensure that people did not write fragile unit tests because they had hard-coded expected ids in asserts.

      There is another problem, where core unit tests assume that, for example, a new Moodle install only has one course category, but a third-party plugin my create a course category for its own use on install.

      In order to prevent these test-breaking assumptions from getting in to Moodle core, perhaps we should change the PHPunit site installer, so that after a default Moodle install, it generates a small random number (0, 1 or 2) of some key entities (e.g. user, course, category, question). These things should be given very specific names, to minimise the change they break existing tests.

      As a specific example, if you install qtype_coderunner, then core_question_privacy_provider_testcase starts failing.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              timhunt Tim Hunt
              Votes:
              5 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: