KeywordUtil.markFaild throws exception at the end of testcase

Hi,

this is my code which is passed and all actions until the end of the test case are beeing performed.
List dateCells = new ArrayList()
dateCells.add(‘//td[@id='userRow27_5_7']/div[last()]’)
dateCells.add(‘//td[@id='userRow27_12_7']/div[last()]’)
dateCells.add(‘//td[@id='userRow27_19_7']/div[last()]’)
dateCells.add(‘//td[@id='userRow27_26_7']/div[last()]’)
dateCells.add(‘//td[@id='userRow27_2_8']/div[last()]’)
for (i = 0; i < dateCells.size; i++) {
String strPath = dateCells.get(i)

int cntEvents = driver.findElements(By.xpath(strPath)).size()
KeywordUtil.markFailed("MARKFAILED by KeywordUtil" );
if (cntEvents < 1) {
	KeywordUtil.markFailed('=====> Failed: cntEvents < 1: 1 was expected !!!!!!!')

	println('=====> Failed: cntEvents < 1: 1 was expected !!!!!!!')
} else {
	println('(\'=====> SUCCESS: Recurrence available')
}
CustomKeywords.'esHelper.es.checkReadiness'('Object Repository/Add and delete recurrence/a_Nchste Woche keyboard_arrow_right')
WebUI.click(findTestObject('Object Repository/Add and delete recurrence/a_Nchste Woche keyboard_arrow_right'))
WebUI.delay(1)

}

… code continues and is executed until the end of test case

After the browser was close I get this exeption:
2019-08-02 11:32:23.584 DEBUG event with validation of the time frame - 92: closeBrowser()
2019-08-02 11:32:24.888 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Add and delete recurrence event with validation of the time frame FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: MARKFAILED by KeywordUtil
at com.kms.katalon.core.util.KeywordUtil.markFailed(KeywordUtil.java:19)
at com.kms.katalon.core.util.KeywordUtil$markFailed.call(Unknown Source)
at Add and delete recurrence event with validation of the time frame.run(Add and delete recurrence event with validation of the time frame:171)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1564738302420.run(TempTestCase1564738302420.groovy:21)

2019-08-02 11:32:24.906 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Add and delete recurrence event with validation of the time frame.

My project settings:
PrjSettings
What can I do to avoid this strange exception?`

Regards,
Matthias

this is what markfailed is supposed to do.
in fact, any failing keyword will throw an exception.
even if you choose to continue on failure (thats why yor code will continue) the testcase remains failed and exception thrown

Hi, remove this line
KeywordUtil.markFailed("MARKFAILED by KeywordUtil" )
It is always executed in your for loop

Hi HeleneB,

this was only inserted for verification if I really always get an exception at the end of the test case as soon as I call KeywordUtil.markFailed. This line KeywordUtil.markFailed(“MARKFAILED by KeywordUtil” ) is removed, but when you look at the real code here:
if (cntEvents < 1) {
KeywordUtil.markFailed(’=====> Failed: cntEvents < 1: 1 was expected !!!’)

println('=====> Failed: cntEvents < 1: 1 was expected !!!!!!!')

} else {
println(’(’=====> SUCCESS: Recurrence available’)
}

KeywordUtil.markFaild is also called for the case that the variable cntEvents is less than 1. How can I switch off the behaviour that Katalon creates the exception at the end of the test case 5 minutes after passing this part of code I sent you??

So, see @Ibus response : this is normal.
If you don’t want the status “Failed” with its error/exception at the end, remove the KeywordUtil.markFailed('=====> Failed: cntEvents < 1: 1 was expected !!!') or replace it with markWarning

Ok, thank you very much for your eye opener. I will switch to markWarning. Have a nice weekend!!

Greetings,
Matthias