Exceptions

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.

Example

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>

Further Details