Return value of failed test case is null


#1

Operating System Windows 10

Katalon Studio Version
5.9.1

Steps to reproduce

Main script:

String cat = WebUI.callTestCase(findTestCase('test1'), [:], FailureHandling.CONTINUE_ON_FAILURE)
println(cat)

test1:

String	cat = "kitten"
println(cat + "!")
try {
CustomKeywords.'my.Customs.testKeyword'()	
}
catch (Unsaved) {
System.out.println('lol')
}
return cat

testKeyword:

def testKeyword() {
println("This keyword is going to fail cause a browser isn't open")
WebUI.navigateToUrl("https://docs.katalon.com/")
return
}

Expected Behavior
I expect the console to spit out “kitten!” “This keyword is going to fail cause a browser isn’t open” “lol” “kitten”

Actual Behavior
You actually end up with “kitten!” “This keyword is going to fail cause a browser isn’t open” “lol” “null

I’ve read other threads about called test cases failing if a catch is triggered inside of it; I can work around that (I was surprised to see in my investigation that it’s failing if it contains a custom keyword, but not failing in simpler scenarios).
But the failed case is also failing to send its return value. For reasons that are long-winded, I really need to send some info back to my main script from a failed test case (more than just “this is why it failed”).

Can anyone think of a workaround?


#2

That’s a bug, 100%.

If you’re seeing “lol” printed, there is no reason why return cat should not work.

Since you have the code at hand to play with, did you try adding a finally block?

// ...
catch (Unsaved) {
  System.out.println('lol')
} finally {
  System.out.println('Trying finally...')
  System.out.println(cat)
  cat = "kitten"
}
return cat

#3

Looks like the finally block executes fine, same as the catch. (Except, of course, if I put return cat into those blocks, that sends back null regardless of where appears)

I think I’ll start restructuring my tests such that anything I need data out of isn’t inside a separate test case.