How can I get the number of steps failed on a test case on Katalon?

I want to know how many steps failed on specific test cases and save on a database. I already have a database my question now is to save the number of test cases that failed on a test suite! Im trying not to use the API, i have tried using a custom keyword so i could get the data from the test suite im using but I can’t access the test suite on the keyword.


I alredy got the total number of steps on a test, did it like this:


Do you want to know which Test Cases passed and which Test Cases failed in a Test Suite?

Then you should use Test Listener, perhaps.

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

class NewTestListener {

	int numberOfFaultyTestCases = 0

	def sampleAfterTestCase(TestCaseContext testCaseContext) {
		println testCaseContext.getTestCaseId()     // MyBrilliantTestCase
		println testCaseContext.getTestCaseStatus() // PASSED, FAILED, ERROR
			if (testCaseContext.getTestCaseStatus() != "PASSED") {
				numberOfFaultyTestCases += 1

	def afterTestSuite(TestSuiteContext testSuiteContext) {
		println("Failed Test Cases: " + numberOfFaultyTestCases)

1 Like

I added import statements into the sample code I showed previously.

1 Like

Thanks for your help!