Actually I'm writing a bunch of tests but I'm not sure how I should handle exceptions/errors best.
There a different types of exceptions, e.g. AssertException
if a result was not as expected using assertThat(..)
. This is O.K. and understandable.
But what if I have a FileNotFound
/ SOAPException
/ DOMException
and so on...?
For example in my @BeforeStory
method I create some testdata by reading testfiles and sending them to a webservice and there I could possibly get the above mentioned exceptions. I would like to present these errors by using an own error message also in the living documentation. But how should I manage this? Actually I'm thinking about two approaches:
1.) I catch the exception and throw my own new exception with an individual error message. The testexecution is aborted for the scenario and the exception is presented in the living documentation.
2.) I catch the exception, implement a string based return statement with the error message and use an assertThat(...)
in my low-level specifications so I only should get AssertException
in the end.
3.) ..?
Question: And advice or common best practices how to handle exceptions or errors with selenium/serenity ?