Stop and mark test case as error from listener

Of course, I should have known that…

Your code in the Test Case is a method (in a Groovy Script class). Your “final” throw has to come from there to stop it in its tracks. Sorry, I really missed the point back there.

For reference, this is how my TCs look:

import ...

public class Test extends com.my_company.some_page_object {
  Test() {
    // Test steps ...

try {
  new Test()
} catch(Exception e) {

So anywhere I perform a throw (or any throw issued by kat code), I get to catch it, deal with the message my way (I write my own reports for example) and then my script method ends.

So it does look like you need to set the stage in the listener and deal with it somewhere in the TC runtime scope (if that makes sense). This also might have been my issue I didn’t investigate properly.

Anyway, hope that gives you food for thought.

1 Like