Trouble creating multiple users using callTestCase

Hi,
In test case 1, I am reading data from excel sheet to create User1.

Test Case 2 needs to create a User2 but with different data and then use that user in testcase 2.
I want to use ‘callTestCase’ in TestCase2 but don’t know how to bypass the instantiating the class of Hash Map.
Right now when I run TestCase2, TestCase1 data is used because of instantiating of data1 and then assigning the data1 with new data.
Shouldn’t I be able to call TestCase1 and create multiple Users?

What can I do so the following two lines are not executed if the call is made from callTestCase?

Thanks in advance!

HashMap<String, String> data1 = new HashMap<>();
data1 = ReaddataFromExcelSheet

TestCase1

HashMap<String, String> data1 = new HashMap<>();
data1 = ReaddataFromExcelSheet

System.out.println("Name = " + data1.get(‘Name’);
System.out.println("Age = " + data1.get(‘Age’);

TestCase2

HashMap<String, String> data1 = new HashMap<>();
data1 = ReaddataFromExcelSheet

WebUI.callTestCase(findTestCase(‘Users/CreateUser’), data1)

1 Like

Hi,

Thank you for letting us know your issue. I will find out more and back to you .

What about creating a Map variable as a Global Variable and pass that between your test cases? The Global Variable is created/instantiated in your Profile and then you don’t have to “instantiate it again” but can “refill” it within your test cases. Just remember to have the below import in all Test Cases.
import internal.GlobalVariable as GlobalVariable

Another way is to create the HashMap variable in the calling program and pass the variable as a parameter into your called Test Cases.

Call test case in Katalon Studio | Katalon Docs

1 Like

Let me try Map global variable. I cannot try the second method, some test cases have more than 30-50 variables, excel sheet is the easiest and fastest way to go. Thanks

GlobalVariable option worked. Thanks

I also added another boolean as a global ‘bCurrentTestCase’ and set it to true.
Before calling callTestCase, I set the bCurrentTestCase= false and I have an if statement when trying to access excel sheet.
if(bCurrentTestCase)
{
data1 = ReaddataFromExcelSheet
}