The function "testCaseContext.message" only returns one error for a test case

I looked at the source of com.kms.katalon.core.main.TestCaseExecutor, Line#279-289 of Katalon Studio v9.0

    public TestResult execute(FailureHandling flowControl) {
        ...
                if (ErrorCollector.getCollector().containsErrors()) {
                    Throwable error = ErrorCollector.getCollector().getFirstError();
                    testCaseResult.setMessage(ExceptionsUtil.getStackTraceForThrowable(error));
                    logger.logError(testCaseResult.getMessage(), null, error);
                    return testCaseResult;
                }
   ...

Please find that ErrorCollector.getCollector().getFirstError() is called to pick the first Exception. The first Exception will be passed into a TestCaseResult, which will be passed to TestListenerā€™s @AfterTestCasee-annotated method.

As this line of code tells, Katalon Studio intentionally picks up only one Exception to be contained in the TestCaseContext. Katalon Studio is designed as such.

Hi @osamazaza200,

Sorry for my late response. Getting the answer from my team, testCaseContext.getMessage() will return a failed message of the first error, not all the errors of the current test case. If you want to retrieve all errors, please raise feature request. Hope this can be clear. Thank you!

I think that @osamazaza200 does not need to wait for Katalon to change their product.

He can write his TestListener like this:

    @AfterTestCase
    public void afterTestCase(TestCaseContext testCaseContext) {
        List<Throwable> errors = ErrorCollector.getCollector().containsErrors()
        ...

This must be what he wanted. Easy, isnā€™t it?


I would recommend you, guys in this user forum, to read the source codes of Katalon Studio, which is bundled in the distributable and installed at

<Katalon Studio installation folder on your PC>/Contents/Eclipse/configuration/resources/source/com.kms.katalon.core/com.kms.katalon.core-source.jar

and other jars nearby.

If you read the source code, then sometimes you would be able to solve your problems yourself.