Record an error message but continue

Is it possible to record a failure message, but continue with the test? I’ve been playing around with ```
FailureHandling.CONTINUE_ON_FAILURE, but still can’t get it to do what I want.

For example, the following generates a failure, but stops script…
if( assertThat( myText ).doesNotContain(‘Fault’) ) { //do something }

Whereas the following continues to “do something”, but does not generate a failure…
if( assertThat( myText, FailureHandling.CONTINUE_ON_FAILURE ).doesNotContain(‘Fault’) ) { //do something }

What is “assertThat”?What is “doesNotContain”? Katalon Studio does not provide them.

Apologies, I didn’t realize that these commands are JUnit, not Katalon. Still learning my way around. However, is there a way to record an error message, but continue with the script?
The way I got around this was to have a boolean “failureEncountered” variable, which I would set to True during the script, and then at the very bottom of my script I deliberately threw an error if it was true (using the assert method). This way the script ran to the end, but didn’t show as a pass if it had an issue.

Yes. If a statement assertThat( myText ).doesNotContain(‘Fault’) throws an Exception, you can enclose it in a try {...} catch {}.

try {
    ....
    assertThat( myText ).doesNotContain(‘Fault’)
    // do something here
} catch (Exception e) {
    // do something here
    KeywordUtil.logWarn(e.message())   // record an error message,
}
// but continue with the script

I do not quite understand your description without looking at your code.

If you want to ask how you should write code, then please share your current Test Case script first, then describe how it actually worked, and how you wish it.

Thanks again kazurayam, you are always such great help.
You pointed me in the right direction, which is to use KeywordUtil.logWarning method. I was only using assertThat because I didn’t know how else to update the log with a warning or failure.