TestSuiteContext Issue

I am using this code in listener but this is not printing test suite id.Do we need to follow any extra step to print test suite ID?


def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
println testSuiteContext.getTestSuiteId()

1 Like

I made Test Cases/TC1 as this:

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

println "TC1 ran"

I made Test Suites/TS1 as this

I made Test Listeners/TL1 as this:

import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.context.TestSuiteContext

class TL1 {

	def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
		println "TestSuiteId is " + testSuiteContext.getTestSuiteId()

When I ran the “Test Suite/TS1”, I got the following output in the console:

2024-02-25 07:50:42.534 INFO  c.k.katalon.core.main.TestSuiteExecutor  - START Test Suites/TS1
2024-02-25 07:50:42.629 INFO  c.k.katalon.core.main.TestSuiteExecutor  - hostName = kazuakiurayama - localhost
2024-02-25 07:50:42.631 INFO  c.k.katalon.core.main.TestSuiteExecutor  - os = Mac OS X 64bit
2024-02-25 07:50:42.633 INFO  c.k.katalon.core.main.TestSuiteExecutor  - hostAddress =
2024-02-25 07:50:42.634 INFO  c.k.katalon.core.main.TestSuiteExecutor  - katalonVersion =
TestSuiteId is Test Suites/TS1
2024-02-25 07:50:42.908 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2024-02-25 07:50:42.908 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TC1
Start recording video for test case 'Test Cases/TC1'.
TC1 ran
2024-02-25 07:50:45.804 INFO  c.k.k.c.c.internal.VideoRecorderService  - Video recording for test case 'Test Cases/TC1' .
2024-02-25 07:50:45.808 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TC1
2024-02-25 07:50:46.137 INFO  com.kms.katalon.core.util.KeywordUtil    - Start generating HTML report folder at: /Users/kazuakiurayama/katalon-workspace/test/Reports/20240225_075036/TS1/20240225_075036...
2024-02-25 07:50:46.192 INFO  com.kms.katalon.core.util.KeywordUtil    - HTML report generated
2024-02-25 07:50:46.194 INFO  com.kms.katalon.core.util.KeywordUtil    - Start generating CSV report folder at: /Users/kazuakiurayama/katalon-workspace/test/Reports/20240225_075036/TS1/20240225_075036...
2024-02-25 07:50:46.222 INFO  com.kms.katalon.core.util.KeywordUtil    - CSV report generated
2024-02-25 07:50:46.311 INFO  c.k.katalon.core.main.TestSuiteExecutor  - --------------------
2024-02-25 07:50:46.311 INFO  c.k.katalon.core.main.TestSuiteExecutor  - END Test Suites/TS1
2024-02-25 07:50:46.311 INFO  c.k.katalon.core.main.TestSuiteExecutor  - ====================

This looks fine. @BeforeTestSuite-annoted method in the TL1 was invoked.

On the other hand, when I ran the Test Case/TC1, I got the following output:

2024-02-25 07:52:57.329 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2024-02-25 07:52:57.333 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TC1
TC1 ran
2024-02-25 07:52:57.599 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TC1


I guess you ran your Test Case, not your Test Suite. Therefore the @BeforeTestSuite-annotated method in the Test Listener wasn’t invoked.

I have test suite:

I have listener as:

When I run Test suite , log d not show suite ID instead all as message is printed:

@antara.kumari you are looking for the result in the wrong place.
the log viewer shows that your testcase executed properly. and the executed command.
and that is fine.
however, will not show the result of the println command.
guess why? because that command will output to the console.
this is how print commands works.
so, perhaps try to look into the other tab?

1 Like


You might be at a loss what the console is. Here it is:

Thank you so much for the clarification.

What you’re looking for is KeywordUtil.logInfo()

1 Like

Thank you my issue is resolved with above suggestions.

Thank you issue is resolved.