KeywordUtil.markFailed and -markFailedAndStop throws exception


#1

Hello

I have seen these errors other Katalon users for a long time.
Is there coming any fix for this bug?
If using KeywordUtil.markFailed(“Your error message”) and/or KeywordUtil.markFailedAndStop(“Your error message”) Katalon throws
“com.kms.katalon.core.exception.StepFailedException”.
And no matter if using “import com.kms.katalon.core.util.KeywordUtil” or/and(together) “import com.kms.katalon.core.util.KeywordUtil as KeywordUtil”.

Example if I use command KeywordUtil.markFailed(“Your error message”) Katalon throws:
com.kms.katalon.core.exception.StepFailedException: Your error message
at com.kms.katalon.core.util.KeywordUtil.markFailed(KeywordUtil.java:19)
at com.kms.katalon.core.util.KeywordUtil$markFailed$2.call(Unknown Source)
at YOUR-test.run(YOUR-test:176)
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 TempTestCase1569834867983.run(TempTestCase1569834867983.groovy:21)

Real solution is not “…don’t use KeywordUtil.markFailed use instead of it KeywordUtil.markWarning -command.”
If I use KeywordUtil.markWarning(“Your error message”), it works.

I have:
Katalon Studio
Version: 6.3.3
Build: 11

Thank you.


#2

Hello,

probably I don’t understand, but what is the issue here?


#3

this is how step failed is working. any step failure will throw an exception. so … where is the bug here? between the chair and keyboard?


#4

“any step failure will throw an exception” ->
In the log, it looks as if the script is defective, that is, it is foolish and causes misunderstanding of the login reader.
So this is waste of time.
Thanks anyway.


#5

yes, it is a waste of time … for both parties, you and the rest of us who spend time for reading the docs of various languages and tools in the attempt to understand how do they works and how to properly use them.
thank you!

i never meet any test framework up to now where a failed assertion won’t throw an exception. and i tried quite few. but who knows … i may need to learn more …


#6

To be fair, you are marking something as “Failed”, inherently that is an exception.
You can add text to the failure to indicate what happened. But in reality there is a failure and the script wasn’t able to continue. It’s not showing the script is defective.


#7

and … if you want the script to continue, read about failure handling.
buuut … i am just a poor guy wasting his time reading the docs, what do i know?
for the ‘real coders’ such behaviour is just a bug …


#8

@jussi.mervio

You may prefer KeywordLogger class to KeywordUtil.

KeywordLogger just logs a message without stack trace.


#9

You can read the source of KeywordUtil class here:

I found KeywordUtil.markWarning(String) and Keywordutil.logInfo(String) are also available. These just calls KeywordLogger without throwing Exception.


#10

To answer the original question posted and for future readers

import com.kms.katalon.core.util.KeywordUtil

try{

catch(Exception e) {

KeywordUtil.markFailed(e)
}