KeywordUtil.markFailed method

Hello, when I use KeywordUtil.markFailed() method, it shows only first fail in execution log. I am wondering if it is possible to log FAILED message each time I call markFailed().


Only first occurrence of markFailed() can be seen. It’s hard to determine in long tests how many markFailed() methods were invoked. How can I solve such a case? Thank you.

I believe I found a solution for such a problem. There is a class called KeywordLogger, which can write into a log. So just create an instance of it and call logFailed() method.

KeywordLogger log = new KeywordLogger()
log.logFailed("Failed 1")
log.logFailed("Failed 2")
log.logFailed("Failed 3")

There are 3 FAILED level logs after execution. And that’s it. :slight_smile:

1 Like

Hi Hung,

yes, I have set up FailureHandling as Continue on failure, so the test case would finish even when there is some failure. I used markFailed on purpose, because there is also markFailedAndStop method, which makes the test stop immediately.

Even this sample test has finished. Please see whole log: (sorry, img tag suddenly stopped working here)

All markFailed methods were invoked, but only Failed 1 message is shown in a log. I’d like to view all 3 messages, this is my original question. Thanks!

Hi Marek,

Unfortunately, the test case is stopped immediately when you call markFailed method. That’s why you only see the first failed step in the Log Viewer.

Katalon Studio provides “Failure Handling” settings for keywords, which allow users to decide to continue running when errors occur during execution. Please have a look here for better understanding. With regards to markFailed method, we should only use this method in a Custom Keyword to mark a keyword failed when it doesn’t meet your expectation.

Hope my answer can solve your concern.

Hi all,

Can you show the different between KeywordLogger and KeywordUtil?
As my observation, I can see that
- log.logFailed" show FAILED step in LogView but the point is the testcase still PASSED. That does not make sense. What is the purpose of this kind of log?

  • KeyworkUtil.markFailed can show failed step and mark testcase failed as my expectation

Please help me clarify about that.

Anh Pham

Hi Anh,

let me explain the difference. The main purpose of this solution is to track all failures across your test case. Let me show you two very simple and descriptive code snippets:

KeywordUtil.markFailed() method really fails your test, but it displays a message only from first failure - this is a problem when you have CONTINUE_ON_FAILURE option for running your tests. You may think that there is only one error.

Instead, you can use KeywordLogger.logFailed() to put all error messages into log folder:

Finally, I have merged those two approaches to create a supper-logger method :slight_smile: You will have both failed test and all messages in a log.

Check it out:

public class CustomLogs {
 * Adds FAILED log message into test case log (and execution is not stopped)
 * @param errMsg
    public static void markStepFailed(String errMsg) {
        KeywordLogger log = new KeywordLogger()
        KeywordUtil.markFailed("One or more failed steps present. Check test report for details.")

Your “main” error message would be the one from markFailed(), but it adds custom error message into test log everytime you call this method. I hope it is more clear now.




Hi Marek Melocik,

Thanks for your reply.

In the instruction, KeywordUtil.markFailed() will mark a keyword failed which mean testcase will be failed as well. This will log failed for all error, not the first one if we implement and call it as a keyword as images below

Call keyword

Implement keyword

About KeywordLogger, I have not found any usage of it, maybe later.


Anh Pham



I am not sure what is your question now.

Hi Marek Melocik,

I just want to say “thank you” and let you know that KeywordUtil is the good choice for my script for now.


Anh Pham

Oh, okay. You’re welcome. :slight_smile:

This issue has been addressed in 6.1.2 beta.