Moodle
  1. Moodle
  2. MDL-22175

Improve unit test failure display

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor 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
    • Rank:
      35757

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

        Activity

        Hide
        Eloy Lafuente (stronk7) added a comment -

        Reopening this after commenting in HQ chat.

        • exception debugging info is not showed anymore and uses to have important information sometimes. Should be back as was before.
        • params should be also shown, not sure if only when the exception->errorcode is untranslated or always, but certainly it also helps.

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Reopening this after commenting in HQ chat. exception debugging info is not showed anymore and uses to have important information sometimes. Should be back as was before. params should be also shown, not sure if only when the exception->errorcode is untranslated or always, but certainly it also helps. Ciao
        Hide
        Tim Hunt added a comment -

        Eloy, any chance of a quick review of exception_display.patch.txt

        Show
        Tim Hunt added a comment - Eloy, any chance of a quick review of exception_display.patch.txt
        Show
        Tim Hunt added a comment - And see http://picasaweb.google.co.uk/tjh238/QuizUI?authkey=Gv1sRgCLvJ05ur-6idiwE#5464455566161071778
        Hide
        Eloy Lafuente (stronk7) added a comment -

        +1 it seems to show everything, the only point is that, as far as get_string() already is showing missing strings, it can sound a bit repetitive? With all debugging/displayerrors enabled? I prefer the excess, anyway.

        Thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - +1 it seems to show everything, the only point is that, as far as get_string() already is showing missing strings, it can sound a bit repetitive? With all debugging/displayerrors enabled? I prefer the excess, anyway. Thanks!
        Hide
        Tim Hunt added a comment -

        Thanks for the suggestions Eloy. Implemented (HEAD only).

        Show
        Tim Hunt added a comment - Thanks for the suggestions Eloy. Implemented (HEAD only).

          People

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

            Dates

            • Created:
              Updated:
              Resolved: