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

Improve unit test failure display

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9.8
    • 1.9.9
    • Unit tests
    • None
    • MOODLE_19_STABLE
    • 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.)

      Attachments

        Activity

          People

            timhunt Tim Hunt
            timhunt Tim Hunt
            Nobody Nobody
            Andrew Lyons, 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:
              Resolved:
              8/Jun/10