The Elvis operator was not enough to meet your requirement.
I have made another solution. Please have a look at my demo project at
I created a Groovy class at "Keywords/my/Params.groovy"
:
package my
/**
* Keywords/my/Params.groovy
*
*/
public class Params extends LinkedHashMap<String, Object> {
private static final Map<String, Object> defaultValues =
[
"foo": 0,
"bar": "default_bar",
"baz": false,
]
Params(Map<String, Object> values) {
super();
this.putAll(defaultValues);
this.putAll(values);
}
}
I made a Test Case script "Test Cases/caller"
:
// Test Cases/caller
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import my.Params
Map params = (Map)new Params(["bar": "Hello, world!"])
WebUI.callTestCase(findTestCase("callee"), ["params": params])
I made one more Test Case script "Test Cases/callee"
:
// Test Cases/callee
println "params.foo=" + params.foo
println "params.bar=" + params.bar
println "params.baz=" + params.baz
When I execute the caller
, I got the following output in the Console:
2022-04-04 18:38:03.701 INFO c.k.katalon.core.main.TestCaseExecutor - CALL Test Cases/callee
params.foo=0
params.bar=Hello, world!
params.baz=false
Please find that the params.foo
is assigned with a default value 0
, the params.baz
is assigned with a defautl value false
.
And the params.bar
has a value Hello, world!
which is passed by the caller script runtime.
Your requirement requires this level of Groovy programming. The Manual mode is no longer enough for you.