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

Improve unit test failure display


    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 1.9.9
    • 1.9.8
    • Unit tests
    • None

      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.)

            timhunt Tim Hunt
            timhunt Tim Hunt
            Nobody Nobody
            0 Vote for this issue
            1 Start watching this issue


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