munit
munit copied to clipboard
Report error contents in traceback slot
When there is an error, the error string is appended to the test name in the top right box. You cannot see the complete error. Can you add the contents to the traceback text? Proposed solution below.
_pragma(classify_level=restricted,topic=MUnit)
_private _method test_failure.init_traceback_text()
## Init slot .traceback_text.
#DEBUG show(:test_failure,:|init_traceback_text()|)
_global !traceback!
_try _with error_variable
a_stream << internal_text_output_stream.new()
!traceback!( a_stream, _unset, _false )
a_traceback_text << a_stream.string
_if ( tb << .raised_condition[:traceback] ) _isnt _unset
_then
a_traceback_text << "".concatenation( tb, a_traceback_text )
_endif
a_traceback_text << a_traceback_text.slice( a_traceback_text.index_of(%-),
a_traceback_text.size )
.traceback_text << a_traceback_text
_when error
_if .traceback_text _is _unset
_then
.traceback_text << write_string( "Error getting traceback text ",
" running on the ", _thisthread.name,
" thread", newline_char,
error_variable.report_contents_string,
a_stream.string )
_endif
_endtry
# START CHANGE (2022/08/18 M Field (FCSI)) :
# record the error contents as well in traceback_text
_if .raised_condition _isnt _unset
_then
.traceback_text << .raised_condition.report_string +
%newline + .traceback_text
_endif
# END CHANGE (2022/08/18 mf)
_endmethod
$