If an exception (or any Throwable) occurs during processing, the exception message is displayed along with a stack trace. The stack trace's visibility can be toggled by a button. The expected value is wrapped in a span, and the actual value is shown as the exception message.
Assuming a Throwable with
the message "My error message",
the expression "myMethod()",
and the following stack trace elements:
| Declaring Class | Method | Filename | Line Number |
|---|---|---|---|
| com.mycompany.MyClass | myMethod | MyClass.java | 4 |
| sun.reflect.NativeMethodAccessorImpl | invoke0 | null | 1 |
| junit.framework.TestCase | runTest | TestCase.java | 164 |
is reported against the following element:
<p>some text</p>
We expect this output:
<p> _
<span class="failure"> _
<del class="expected">some text</del> _
</span> _
<span class="exceptionMessage">My error message</span> _
<input class="stackTraceButton" id="stackTraceButton1" type="button" _
onclick="javascript:toggleStackTrace('1')" value="View Stack" /> _
<div class="stackTrace" id="stackTrace1"> _
<p>While evaluating expression: <code>myMethod()</code></p> _
<div class="stackTraceExceptionMessage">java.lang.Throwable: My error message</div> _
<div class="stackTraceEntry">at com.mycompany.MyClass.myMethod (MyClass.java:4)</div> _
<div class="stackTraceEntry">at sun.reflect.NativeMethodAccessorImpl.invoke0 (Unknown Source)</div> _
<div class="stackTraceEntry">at junit.framework.TestCase.runTest (TestCase.java:164)</div> _
</div> _
</p>