03 - Throwing exceptions

When the result of the test is not the expected result, Squash TA should throw an exception. Every exceptions will be logged in the console, and the first thrown for each test will be recorded in the surefire-report.

There is basically two types of exceptions: those which lead to a failure status and those which lead to an error status.

To put it simply, failures are the "expected" exceptions and errors are the "unexpected" exceptions.

Failure exceptions

To be considered as a failure exception, a personnalized exception must extends the class org.squashtest.ta.framework.exception.AssertionFailedException.

Here are two generic types of failure exceptions already defined in Squash-TA (in the package org.squashtest.ta.framework.exception) which can be useful:

Error exceptions

To be considered as an error exception, a personnalized exception must extends the class org.squashtest.ta.framework.exception.BrokenTestException.

Here are three generic types of error exceptions already defined in Squash-TA (also in the package org.squashtest.ta.framework.exception) which can be useful:

There are many other exceptions defined in Squash-TA, for example in the packages org.squashtest.ta.backbone.exception, but they are more specific and should then be less useful.

Feel free to create your own exception if you need to, to help your users to know what is wrong!