Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-37779 unit test fixing META
  3. MDL-37782

Provide better isolation of database test cases when transactions are being used

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.3.7, 2.4.4
    • 2.3.4, 2.4.1, 2.5
    • Unit tests
    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_23_STABLE, MOODLE_24_STABLE
    • w13_MDL-37782_m25_testtrans
    • Hide

      1/ run mysql DML tests
      2/ hack test_onelevel_rollback() as described in description
      3/ run mysql DML tests again - only one more failure expected

      Show
      1/ run mysql DML tests 2/ hack test_onelevel_rollback() as described in description 3/ run mysql DML tests again - only one more failure expected

      After detecting a lot of "new" surprise/errors in the MSSQL driver, it was detected that any (real) failure in the test_onelevel_rollback() test case was affecting to all the rest of transaction test cases in lib/dml/tests/dml_test.php

      The ultimate cause is that the 1st test case leaves open one transaction, so all the next test cases fail badly.

      To reproduce it (under any database):

      1) Edit lib/dml/tests/dml_test.php

      2) Go to test_onelevel_rollback() and addd this line:

      $this->assertTrue(false);
      

      Before any of the allow_commit() calls in the method.

      (that will cause the testcase to stop, so the allow_coomit (close transactions is never executed).

      3) run "phpunit dml_testcase lib/dml/tests/dml_test.php"

      4) You will get various failures in other test cases because 2 left the transaction open.

      While this can be easily prevented in tearDown() or friends... surely the safest way is to close any transaction as part of the standard "reset" thing, to guarantee real test case independence.

      Ciao

            skodak Petr Skoda
            stronk7 Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Frédéric Massart Frédéric Massart
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.