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

Review test-cases inheritance tree and ensure that parents don't have own tests

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.6, 3.10.3, 3.11, 4.0
    • Fix Version/s: None
    • Component/s: Unit tests
    • Labels:
      None
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE

      Description

      This was detected @ MDL-69102 but there maybe other places where the same is happening.

      All our tests-cases are descendants of base_testcase, then basic and advanced, then others, that can also have descendants... and so on. See partial map below:

      This inheritance tree/schema is useful to be able to provide similar testing facilities by component, say questions, say an activity...

      But it has a trade-off that we must avoid at all costs:

      The intermediate test-cases (being parents) in the tree/schema cannot have unit-tests by themselves (aka, cannot have test_xxxx methods). Only "final" test-cases (those not being parents, can.

      Why? Because if a test-case has one test_xxxx method... and it's the parent of, say, 10 children test-cases.... then the test_xxxx unit-test will be executed 11 times in total. A complete waste of process and time.

      The problem is really easy to reproduce, just crate new test-cases extending some existing test-case, run tests and compare the number of unit-tests executed... magically they will increase by the number of unit-tests in the parent test-case.

      A current existing example of the problem is, for example:

      class events_test extends badgeslib_test
      

      If you run with the --filter option any of the unit-tests you will see that, always, 2 tests are executed: the original in badgeslib_test and the "inherited" in events_test.

      So, this issue is about:

      1) generate the complete tree/class-map of all the existing test-cases in core.
      2) find parents in the tree having unit tests (test_xxxx methods)
      3) move them away from parents to new child.
      4) ideally, keep this controlled in a continuous way.

      Ciao

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: