Is there any possibility to trigger a method whenever a testcase or assertion fails, in order to do some things when a testcase fails (e.g. Screenshot while UI-Testing, writing an error log, and so on...).
Maybe there is something like an annotation, I did not yet notice.
Thanks in advance!
You can use the
TestWatcher
rule and implement your ownfailed
method to take a screenshot or whatever you need to do upon test failure. Slightly modified example from the official documentation: