I would like to understand why this annotation does not work when a method is created in the Script tab of a Test Suite.
My Test Suite Script code:
Log viewer:
As you can see, the first test case fails but the “tearDownIfFailed()” method does not execute at all. Instead, the next test case in the suite starts to execute. You can see that “setUpTestCase()” runs as expected with the annotation “@SetupTestCase”.
Other similar posts (like this one @TearDownIfPassed, @TearDownIfPassed, @TearDownIfFailed not working) explain that these annotations worked from the Test Case level. I want to understand why it isn’t working at the Test Suite level.
Hi @jpotrawski
The annotation @TearDownnIfFailed
is applicable on the Test Case level. If your Test Case looks like this:
KeywordUtil.markFailedAndStop('Make it fail')
@com.kms.katalon.core.annotation.TearDownIfFailed
def tearDownIfFailed() {
println "printing things ..."
}
Then you would see the method gets executed:
There’s a documentation here which describes this, but I admit it’s not clear that it’s applicable only on the Test Case level. We will improve it.
https://docs.katalon.com/katalon-studio/docs/fixtures-listeners.html#in-script-view
For your main concern, I think you can create a Test Listener and check if the status is failed and initiate your clean up logic.
1 Like