Is there any way to skip TearDown Test Case for single test in test suite

I have a TearDown Test Case to refresh after every test case.
It is working fine however foe the last test case "logout " it fails (that is obvious as app is not present after logout).
Now I want that TearDown test case not to run for logout test case, is there any way to skip this for one test case?

Thanks in advance.

1 Like

Use a Test Case listener instead – you’ll have access to the Test Case id.

	 * Executes after every test case ends.
	 * @param testCaseContext related information of the executed test case.
	def sampleAfterTestCase(TestCaseContext testCaseContext) {
		println testCaseContext.getTestCaseId()
		println testCaseContext.getTestCaseStatus()

Several questions

This invites several questions:

  • how many test cases are in your test suite?
  • why is Logout one of the test cases in the test suite?
  • what are you trying to accomplish by refreshing the browser after the test case is done?

It also seems like none of these test cases are runnable on their own…

To answer YOUR specific question

It is not the question that you asked, but it is one that is obvious from reading your screenshots, and @Russ_Thomas suggested it: use a Test Listener. To that, I will suggest that what you’re tryna do, refresh the browser window after each Test Case, is a YAGNI (You Ain’t Gonna Need It).

How to use Test Listener

In your specific case, I would advise you set up and close the WebDriver before and after each test case, respectively…

Step 1: Create Custom Keyword for WebDriver Utils

I yoinked this from my project, and took out the SetUpDriver() instance. May it guide you…


import org.openqa.selenium.WebDriver

import com.kms.katalon.core.webui.driver.DriverFactory

import internal.GlobalVariable

public final class SMDWebDriverUtils {
	private static WebDriver driver;

	public static void SetUpDriver() {
		 * TODO: set up this.driver, in accordance to your use case. 
		 * In our real project, we have two  Global Variables it depends on: 
		 *	 - pathToKatalon
		 *	 - pathToUserDataDir


	public static void CloseDriver() {
		if (this.driver != null)

	public static void DoWebAction(Closure onAction) {



Step 2: Create Test Listener

Your Test Listener should look something like this:

import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.context.TestCaseContext


class NewTestListener { 
	/*** Executes before every test case starts.
	 * @param testCaseContext related information of the executed test case.
	def sampleBeforeTestCase(TestCaseContext testCaseContext) {

	def sampleAfterTestCase(TestCaseContext testCaseContext) {

There! Now you don’t have to worry about refreshing your window after test case completion…or even opening the browser window for that matter…because you’re starting anew with each test case!

If you MUST do web action after test case completion…

Notice that I have given you, for free, a method in SMDWebDriverUtils called DoWebAction. In your tearDownTestCase(), simply use it like this:

SMDWebDriverUtils.DoWebAction { 
	// TODO: test-suite-specific teardown logic, involving the browser being open, goes here...

The browser window will open right back up, perform the actions you spell out in the callback (they’re called Closures in Groovy), and close the browser for you, all between the test cases!

Obviously, I would suggest this for reasons other than needing to refresh a browser window…

If you MUST do something AFTER a specific test case is used…

…My suggestion to you would be to do it in the test case itself, like this:

import com.kms.katalon.core.annotation.TearDown

// ...your test case logic...

void close() { 
	// TODO: perform your test-case teardown here...

You could get the name of the test case you’re tearing down, but only if the last step it touches isn’t running some child test case, with this keyword:


import com.kms.katalon.core.configuration.RunConfiguration

public final class SMDTestCaseUtils {
	public static String CurrentTestCaseKey = "current_testcase";
	public static final String GetTestCaseName() {
		return RunConfiguration.getExecutionProperties().get(this.CurrentTestCaseKey);

If your test case doesn’t contain any child test cases, SMDTestCaseUtils.GetTestCaseName() will return the name of the test case you are tearing down, even in the tearDownTestCase() method.

Else, it will return the name of the child-most test case, if calling it is the last step in your test case. A Test Listener will get around that problem.