How to pass bollean as a parameter into callTestCase()?

How to pass bollean as a parameter into callTestCase()? I’ve tried using

a) false
b) variable that was set to false
c) null

Nothing seems to be working. It just keeps using the Default value of the variable in the test I’m calling.

Hi @gdearest07, Try creating your variable as a Global Variable:

1 Like

Are you passing a boolean into a called Test Case or trying to get a boolean value out of a Test Case? Go for the Global Variables, especially if you are passing more than one result.

Passing out of a TestCase

I tried this on KS 7.5.5"

boolean done = false;

done = WebUI.callTestCase(findTestCase('Test'), [myBoolean: false, what: "two"], FailureHandling.OPTIONAL)

println("your result is ${done}")
WebUI.comment("your result is ${done}")

and in my TC that I called, I had:

boolean hasFound = true;

return hasFound;

1 Like

@grylion54 , I’m trying to pass a boolean into a called Test Case. I apologize for the confusion and I do appreciate yours and @Dave_Evers’ replies.

shouldn’t you be able to have one of your Map components as:

WebUI.callTestCase(findTestCase('Test'), [('myBoolean'): false], FailureHandling.OPTIONAL)

Edit: I did some tests and I made a change to the above statement.

I thought I should but for some reason it’s not working. To be precise, in my case it’s something like this:

WebUI.callTestCase(findTestCase(‘Test’), [(myString): ‘string’, (myBoolean): false], FailureHandling.OPTIONAL)

The ‘string’ is getting passed, but false is not.

Are you printing/displaying the Map variables in the called Test Case (just to be sure)? You can always add, myBoolean.toString() to display it’s contents.

Another (poor) option is to pass the boolean like a String, (e.g. “false” or myBoolean.toString()) and then use parseBoolean to get your boolean back again.

1 Like

I’m just printing something like

println('myBoolean : ’ + myBoolean)

but it is always printing the Default value of the myBoolean, not the value I’m trying to pass.

Sorry, but are you initializing your boolean variable within your called TC? Because if you are, that would be the source of your concern. Do not initialize the variable (e.g. myBoolean) in your called TC. It should have an underline in the called TC indicating that it is undefined–but don’t worry (as long as it is spelled correctly).

Here is an exampe:

1 Like

In my called TC, the variable is in Variables and since it’s Boolean it should be either true or false:


So, I’m not sure how it’s possible not to initialize it.

The boolean value is supposed to be passed into the called TC by the originating TC. It should be initialized in the originating TC, but not in the called TC. Try a test with the variable in Variables removed from the called TC and see if your “myBoolean” displays as you want it to afterwards.

1 Like

@gdearest07, could you please help to let us know:

  • Which version of Katalon you are using?
  • Which OS you are using?

From my side, I have Sub Test Case with 2 variables v1 (string) and v2 (boolean) as below screenshot

After that, create another main script to call to this sub test case

  1. With value override: correct value printed (boolean is override from true → false)

  2. With default value: boolean still keep its value as true (expected)

Hope it will be useful for the ways we use Katalon


1 Like

Thank you, @grylion54. I’ll give it a try. Though

  1. Initialisation of the String variable in the called TC is not a problem when passing the string from the originating testcase. So, why is it a problem in case of initialisation of the Boolean variable?

  2. In my case it might be better to use this:

“Another (poor) option is to pass the boolean like a String, (e.g. “false” or myBoolean.toString()) and then use parseBoolean to get your boolean back again.”

What I’m trying to do is to modify my existing testcase (the called TC,currently it has no boolean and is called in multiple testcases) so it can change its behavior (depending on the new boolean variable) but without modifying the other testcases that are already using the called TC. My plan was to use the Default value for existing tests and pass the values only for the new testcases.

Thanks, @loc.nguyen. It’s exactly how I expected it to work.


Windows 11 Pro