How to skip all remaining tests if initial login test fails?

So, I have a test that logs in my user. In the chance that it fails, I’d like the whole suite to just shutdown. Is there a way in the TestListeners @BeforeTestCase to grab the results of the failed first test and then stop the remaining tests and mark the whole suite as failed?

I feel like there is but I’m no 100% sure how to write it to grab the initial result and pass/fail rest of the suite based on that.

Thanks in advance!


I found a topic very similar to yours, have a read through. It appears to have a solution attatched so hopefully it helps you out :slight_smile:

If not, let us know

It’s similar BUT doing it that way you have to write a way to end each test individually and not the whole suite. Looking for a way to mark the initial login as failed and then stop the entire test from running.

EDIT: this works to fail each test individually, but it doesn’t stop the whole suite from running. For example, utilizing the KeywordUtil.markFailed('Unable to login modal found') I’ve been able to end the tests after the modal has been identified but I still have to wait for the entire test suite to complete rather than stop.

@Amanda_Perkins1 yeap I found the same problem like you, we have to run every test.

So it’s not my favourite solution because I have to call this on every SetupTesCase() when I should prefer to stop all the suit immediate but least didn’t run the entire test

First of all, save the status at the finish test case run creating a string global variable

	def AfterTestCase(TestCaseContext testCaseContext) {
		GlobalVariable.TestCaseStatus= testCaseContext.getTestCaseStatus();
Test Suit Script

@SetupTestCase(skipped = false)
def setupTestCase() {
// Put your code here.
if(GlobalVariable.TestCaseStatus==“FAILED” || GlobalVariable.TestCaseStatus==“ERROR”){
KeywordUtil.markFailedAndStop(‘ERROR: The previous test fail’)


I have to use in the listener that condition because when I mark as Failed or as Error in the previous test that test Fails RIGHT! but his status is still PASSED when I get testCaseContext.getTestCaseStatus() so that’s the reason (I think maybe this is some error by katalon) :confused:

Similar to @rodrigocalabretta, I have got a solution to this: