Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.9.8
-
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.)