Test Fixtures and Test Listeners (Test Hooks)


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/fixtures-listeners.html

@Shin

The sample code of Test Listener shown in this document page misses import statements. The sample should include all of necessary import statements; otherwise people would get lost.

import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.AfterTestSuite
import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.context.TestCaseContext
import com.kms.katalon.core.context.TestSuiteContext
import internal.GlobalVariable as GlobalVariable

How to terminate execution gracefully if setUp() cannot complete?

What do you mean by saying “cannot complete”?

If a method is never-ending (10 minutes, 10 hours, 10 days, … ), you can not be graceful about it. All you can do will be just killing the process.

I mean the conditions in the environment mean the test cannot be successful and no test should be run. I’ve found the solution. Test Listeners @BeforeTestCase and @BeforeTestSuite will still run tests even if you throw exceptions, but @Setup and @SetupTestCase will abort execution when errors thrown.

Would you agree with closing your question as “solved”?