How to Pass a dynamic variable from one test suite to another?

I have 2 applications-Policy and Billing.
I have 2 Test suites-1 for Policy,1 for Billing.
I need the Policy Number Generated from Test Suite1(Policy) to be fed into Test Suite2(Billing).

Solutions tried:
1.Storing PolicyNumber into GlobalVariable.gPolicyNumber variable in Test Suite1 but then when trying to use the Global Variable into TestSuite2 it is not able to search the PolicyNumber in Billing.

  1. Tried Writing the PolicyNumber field into an Excel in DataFiles section.
    Problem: Although the Policy Number gets written in Excel,when the Test Suite 2 runs in sequential mode it picks the PolicyNumber of last Iteration and not the current updated Iteration.

Ex: Test Suite1 Iteration#1 PolicyNumber stored in Excel: ABC123
Test Suite1 Iteration#2 PolicyNumber stored in Excel: XYZ123
When the TestSuite2 runs in Iteration#2 it picks the old PolicyData from Iteration#1 and searches in Billing system.
Not sure what is wrong.

Is there any alternate approach to this?

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.


I understand that you want to reuse “the Policy Number” in multiple Test Suites in a Test Suite Collection.

You chose a wrong path.

Two Test Suites in a TestSuiteCollection share nothing on memory. They can share only files on disk. TestSuiteA and TestSuiteB can not share anything on memory (e.g, a GlobalVariable value). So you should stop using Test Suite Collection. You should go for other ways of modularization.

Way 1: Test Cases in a Test Suite can share GlobalVariables

Let me assume a Test Suite includes 2 test cases, TestCase1 and TestCase2. So the TestCase1 can create a Policy Number and save it into a GlobalVariable.policyNumber; then the TestCase2 can refer to the GlobalVariable.policyNumber.

Way 2: Pass parameters via callTestCase() keyword

The callTestCase(calleeTestCase, params) keyword is more light-weight approach to share variable values. Your parent TestCaseC can call other Test Cases, TestCaseA and TestCaseB, while passing any value to the callees A and B. And a callee A can return any value to the caller TestCaseC.

1 Like

You should be able to merge the Test Suite1 and the Test Suite2 into a single TestSuiteUnited, Then the TestSuiteUnited will work fine. The PolicyNumber in a GlobalVariable will be shared by all the test cases in the TestSuiteUnited.

This description suggests to me that you are dependent on the “Data-Driven testing” of Katalon Studio.

The “Data-Driven Testing” feature of Katalon is desinged with an assumption that the data source file (.xlsx, .csv) is given static. Katalon will load the file only once. Katallon will never reflesh its memory during a run. Katalon does not monitor any updates into the data source .xlsx file.

This seems to be a limitation that katalon is unable to render the latest generated test data in excel.
Also, i observed there is no option to modify the excel data directly in katalon.

Let’s say i have loaded the test data once.
Next Time i need to update some test data, i cannot do it from katalon UI. Instead i will have to modify the excel file and replace it with the existing one in data folder.

Thanks for the input @kazurayam.
The problem is there are different teams working on different modules. Policy Team creates their own module, Billing Team creates their own module. So we have different test suites prepared by different teams. That is the reason why i was going for test suite collection so that other team doesn’t modify the test suite of other team.
Combining the test cases into one test suite would mean, i need to copy the Policy Team multiple testcases(20) every time i need to create a Billing Test Suite which could have been avoided if i took their complete test suite in a test suite collection.

OK. I understand that you have a good reason to use 2 Tes Suites; one for the Policy Team, anothe rfor the Billing Team.

However, as Katalon Studio is designed as such, 2 Test Suite can share nothing in memory. Taking this restriction given, you should review the design of your project.

I have a simple advice: You can create 2 folders in the Test Cases folder: like

スクリーンショット 2024-06-18 121633

I suppose that this way you can organize your test cases well. Isn’t it enough?

Now let me go back the the original post where you wrote:

I don’t undestand this explanation. So, I do not really see what’s your problem yet.

What is “Iteration#1” and “Iteration#2”? The term “Iteration” is not defined in the Katalon terminologies, so you should clarify what “Iteration” means.

1 Like

Iteration# is nothing but Round of execution.
Both the Test Suite#1 and Test Suite#2 runs sequentially as a suite collection for every round of execution.

So, in first round of execution of Test Suite#1(Policy System)-system generated Policy#: ABC123 and stored it in excel.
In Second round of execution of Test Suite#1(Policy System)-system generated Policy#: XYZ123 and stored it in excel.
Test Suite#2(Billing System) when it runs in second round, it picks the Policy#: ABC123 of Round1 insead of picking latest Policy#:XYZ123 from excel.

This description is ambiguous, makes me puzzled.

Among the following 3 cases, which is reailly the case?

Case A

You have a Test Suite Collection( TSC0) which binds Test Suite1 and Test Suite2 in the sequential mode. You execute the TSC0 twice. In this case, you will see

  1. Test Suite1 runs in the first iteration
  2. Test Suite2 runs in the first iteration
  3. Test Suite1 runs in the second iteration


You do not use Test Suite Collection. You execute each TestSuites manually as …

  1. Test Suite1 runs
  2. Test Suite2 runs
  3. Test Suite1 runs in the second iteration
  4. Test Suite2 runs in the second iteration

Case C

You do not use Test Suite Collection. You execute each TestSuites manually as …

  1. Test Suite1 runs
  2. Test Suite1 runs in the second iteration
  3. Test Suite2 runs
  4. Test Suite2 runs in the second iteration
1 Like

It seems that the Case A is the case for you. If so,

  1. In theTSC0 as 1st iteration, Test Suite1 runs — system generated Policy# ABC123 and stored in the Excel file
  2. In the TSC0 as 1st iteration, Test Suite2 runs — picks up the Policy#ABC123

  1. In the TSC0 as 2nd iteration, Test Suite1 runs — system generated Polic#XYZ123 and stored in the Excel file
  2. In the TSC0 as 2nd iteration, Test Suite2 runs — picks up the Policy#XYZ123

This looks just reasonable to me. Any problem?

What do you expect to see otherwise?

You are right. My Case is Case A.
The ideal case should be
4.Test Suite2 should pick Policy#XYZ123 but in contrary it is picking Policy#ABC123 generated in Iteration#1, don’t know how from Excel.

You are write. Katalon Studio GUI does not provide a built-in feature to write data into Excel files.

A feasible option is to use the following plugin.

This will let your test case to update your .xlsx file. I haven’t tried it, but it should work.

If you just want to pass a string value from TestSuite#1 to TestSuite#2,
it would be much easier pass the data via local a JSON file.
TestSuite#1 writes a string into an ad-hoc JSON file, TestSuite#2 reads it

Creating, reading, writing JSON is easy. Far easier than working with Excel. See the following post:

However, I would still recommend you to merge your TestSuite#1 and TestSuite#2 into TestSuiteUnited where you use GlobalVariable to share the data as parameters. That’s the simplest and easiest.

I merged the 2 test suites. Although it was a tedious task, however i did it.
I used Global Variable for storing dynamic data and passed into Billing scripts. It is working as expected now. Thanks!
Will have to figure out why the excel latest data is not picked. Maybe try the excel steps in the merged test suite to see if it changes anything.
Just wanted to know will json file will be able to keep latest generated data or it will behave same as excel?

Still I don’t understand your question.

Still I don’t understand your your Test Case script managed to write data into your .xlsx file.

Please describe how you tried to write data into your .xlsx file.

… here I guess that you haven’t succeeded to serialize any data into your .xlsx file; but you BELIEVE you have managed, which I doubt.

Did you called the Apache POI API?

Did you use the Katalon’s Excel plugin?

Or any other way? (though I can’t imagin any other)

import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration

String filePath =
RunConfiguration.getProjectDir() + ‘/DataFiles/Billing/B_PolicyNumber.xlsx’

CustomKeywords.‘common.Excel.writeToExcel’(filePath, ‘Sheet1’, 1, 0, PolicyNumber)

Writing the Policy Number in Excel, Then using the Policy Number into Billing script using Data Binding.

I am using Global Variable approach and discarded the Excel approach as a final solution.

Good decision, I think.

@kazurayam can you please share your thoughts on
Division Operation in Katalon.