FitNesseRoot.Fitnesse.UserGuide.WritingAcceptanceTests.SliM.ExceptionHandling.content.txt Maven / Gradle / Ivy
!2 Default Handling of exceptions.
The default way Slim handles exceptions is to indicate in the test table that an exception was thrown, and increment the exceptions count for the test. You will also find the full stack trace for the exception is listed at the top of the test. Slim will then try and continue on with the test.
!2 Specifying a custom message
You can specify a custom message to be written into the test output instead of a stack trace. This is done by prefixing your message with {{{message:<<}}} and ending with {{{>>}}} For instance if you want the message to be "Can't create object" then the text for your exception should be {{{message:<>}}}
!2 Stopping the execution of the test.
If your exception indicates an error that cannot be recovered from, then you may want the test execution to stop at that point. You can do this by throwing an exception with "!-StopTest-!" in the class name. If the test is part of a suite, then this will cause the next test in the suite to be be started immediately.
Be warned, that if you throw a "!-StopTest-!" exception then the tear down for your test will not run. A fix for this is to run the tear down procedure before you throw the exception.