How to stop a testcase even if it passed

Does anyone know if there is a way to set the status of a testcase to failed even if it passed?

You can force a Test Case to stop with this keyword:

   * Debugging helper.
  static void FORCESTOP(String msg = "") {
    WebUI.comment("FORCESTOP..." + msg)
    throw new StepErrorException("FORCESTOP" + (msg ? ": " + msg : ""))

You can post a failure message and stop the TestCase with this…

   * Prints a failure message to the KS log and stops the test.
   * @param msg (String) The content of the message.
  static void markFailed(String msg) {
    throw new StepErrorException(msg)

You want StepFailedException, not StepErrorException.

The code will require an import statement:

import com.kms.katalon.core.exception.StepFailedException
1 Like

Thank you for your help @Russ_Thomas and @kazurayam

1 Like