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

Improve unit test failure display

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.8
    • Fix Version/s: 1.9.9
    • Component/s: Unit tests
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      Suppose, to organise your unit tests, you make a helper function, like $this->check_current_output(...), that does a whole bunch of asserts, and which you call from a number of different test methods.

      At the moment, the failure message will point to the line of code in the check_current_output method, which is not very helpful.

      The attached patch tries to do more helpful output by displaying the stack-trace of where the failure occurred.

      However, when running simple-tests the full stack trace is very long, with lots of simple-test related stuff in it.

      Therefore, this code strips all the irrelevant bits out of the stack trace, so that only your code remains. Then the trace is only displayed if more than one bit remains.

      (The patch is for 2.0. In 1.9, we can't use format_backtrace. There, I will just use print_object.)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  8/Jun/10