Mark test Passed and stop?

I understand there is a Keyword to manually mark tests pass or fail but it doesn’t look like there is a way to mark the test passed and then end the test. Is there any way to end the test after marking it passed?

I tried using DriverFactory.getWebDriver().quit() but this only closes the driver while the execution still continues.

If you’re marking this in the script for a test case and not a custom keyword or function, try this, perhaps:

import com.kms.katalon.core.util.KeywordUtil as KeywordUtil
/* Your test case steps */
KeywordUtil.markPassed("Your log message here")
return null
1 Like

Oh wow I didn’t realize I needed the return null part. Thank you!

Is there something else that needs to be done if you are using this in a custom keyword? It looks like your solution works when I use it in the script but not in the keyword.

You could try wrapping the call to the custom keyword in an if statement, such as:

if(PassTest(/* Your arguments */)) {
    return null   //Halt if PassTest is true
//Continue your test case if PassTest is false

Set up the PassTest keyword to return true if KeywordUtil.markPassed("") is triggered, and false if it isn’t.

That is because when this is hosted in your test case script…

… it is returning early from the script class run method which hosts your test case script.

(Take a moment to digest that last statement).

When you return from your keyword method, you’re merely returning early from your keyword method – probably returning right back into your run method in your test case script.

“But I don’t have a run method!"

You very probably do. That’s how Groovy works. And I don’t think Katalon messes much with that setup. See:


Is there a way to return early on the script FROM the keyword? Or is there perhaps another way to end the script at the keyword level?

You could try doing what @michael.hollander suggested, wrapping the call to your keyword and detecting when it exited early.

However, I have to say this, your approach is not something I would choose to do. I am not saying it’s wrong, I’m just saying, I wouldn’t do it like that myself. The only time I ever “exit early” is when there’s a problem. You might find it easier to think of a “pass” as having executed “everything” through to the end (which is how I think of it). I just can’t settle with a pass being something that exited early. Sorry.

Ultimately what I am trying to do is handle feature toggling. I’m trying to get the keyword to see if the toggle is on or off. If its on then do the steps for the new feature AND end the test (since the old steps no longer apply here). If the toggle is off then continue with the original steps in the script.

I’m approaching this as a quick fix of inserting a keyword into the script without having refactor or remove the old steps.

if(feature present) {
  call test this feature
} else {
  call other stuff
1 Like

Thank you. This is how I’ll fix my issue but out of curiosity there is no way to mark a test passed and end the script from a keyword?