Different result for starting Test suite directly in Katalon and for calling it via command line

Hallo Katalon Community!

I have a Web Service project where I test APIs.
In some cases, my test suite/ test case is successful if I start the Test suite directly in Katalon.
But when calling the test suite in jenkins via command line it fails with an error.
(I think I also noticed other small discrepancies in the past like slightly different decimals for numbers with a lot of decimals)

It would be very helpful if I could see the error already when I start my test suite directly in Katalon. Do you have any idea why I get a different result for starting the test suite directly in Katalon and for calling the test suite via command line? How can I achieve the same behavior for both scenarios?

Here an example:
I wanted to use getElementPropertyValue to get the “KI_ISOELECTRIC_POINT” from my resonse.
The response json looks like this:

{
(...)

"KI_ISOELECTRIC_POINT":6.24

(...)
}

a) I tested with Katalon Version 8.6.9 (JavaSE-1.8) as well as with Katalon Version 10.1.0 (JavaSE-17) by starting the Test suite directly in Katalon and it is successful:

b) however, calling this test suite via command line fails with Error:

I would be great if you have an idea how I can get the same behavior in both scenarios, as I’ve been struggling with this for quite some time.

Best regards
Conny

1 Like

it seems that there is something wrong with Keyinfo.ki__

print the response to verify

KeywordUtil.logInfo(response.getResponseText())

Hi Monty_Bagati, thank you very much for your quick reply!
I added KeywordUtil.logInfo(response.getResponseText()).
“KI_ISOELECTRIC_POINT” looks “normal” in the response both via Katalon and via CMD/command line.
report:


cmd:
grafik

Can it be that the json response is somehow handled differenty via Katalon directly and via CMD command line/ Katalon engine?

Use the below instead of getelementpropertyvalue

import groovy.json.JsonSlurper
def jsonResponse = new JsonSlurper().parseText(response.getResponseText())
def testKI = jsonResponse.keyInfo?.KI_ISOELECTRIC_POINT
if (testKI != null) {
KeywordUtil.logInfo(testKI.toString())
} else {
KeywordUtil.markFailed(“KI_ISOELECTRIC_POINT key not found in response!”)
}

Thank you very much! I’ll use your solution instead.

Only one last question: There is still the issue that the code with getElementPropertyValue seemed to be working fine when I click Run Test Case or test suite in Katalon directy.
So I always have to re-check via Jenkins/command line if my code really works or if I have to improve it?
There is no way that I can enforce the same behavior for running my TC directly in Katalon and for running it via the command lie (i.e. that I see the error either in both cases or in none)?

Did the above solution work?

Katalon studio might be automatically adjusting the response internally. After all katalon studio is an IDE

But in cli , it might be treating as a raw string instead of a json object.

What works in ides may not always work in cli or pipelines and hence we need to adjust our tests sometimes

Thanks for the explanation! Then I’ll always re-check via command line after creating a new test case / suite.

I checked the last run via Jenkins and your solution worked fine, thanks!