Another alternative approach would be to merge the 2 or more Test Suites into a single Test Suite. In the scope of the merged Test Suite, all GlobalVariables will be shared. In other words, I would recommend you not to use any Test Suite Collection.
Let me briefly explain my idea here. Let me assume that you have a set of Test Cases:
[
[TestCaseA1g, TestCaseA1h],
[TestCaseA2j, TestCaseA2k],
[TestCaseB3m, TestCaseB3n],
[TestCaseB3p, TestCaseB3q],
]
And you have made a project with 2 TestSuiteCollections; namely TestSuiteCollectionA and TestSuiteCollectionB.
The TestSuiteCollectionA binds 2 TestSuites; namely TestSuiteA1 and TestSuiteA2. The TestSuiteCollectionB bunds 2 TestSuites; namely TestSuiteB1 and TestSuiteB2. The TestSuites comprise with the worker Test Cases (TestCaseA1g, TestCaseA1h, and so on) as the following diagram shows.
I would like to call this project structure as High-rise project.
Now I would set a condition that the TestCaseA1g updates a GlobalVariable.X, which the following TestCaseB3q needs to refer to. In the High-rise project, this condition will never be met. It is a design fault that I locate the TestCaseA1g and the TestCaseB3q into different TestSuites, as these 2 test cases need to share a GlobalVariable.X.
Now, I want to reform the project structure so that it uses NO TestSuiteCollection and uses only a single Test Suite which contains all the Test Cases.
I can reform the above project as follows:
I would like to call this project structure as Low-rise project.
In the Low-rise project, I introduced several new Test Cases named TestCaseC1, TestCaseC2, TestCaseC3, TestCaseC4. I will call them as Controllers. The Controllers will calls the worker Test Cases using the WebUI.callTestCase() keyword ; that’s all the Controller does.
For example, the source code of TestCaseC1 will look like this:
// TestCaseC1
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
WebUI.callTestCase(findTestCase("Test Cases/TestCaseA1g"), [:])
WebUI.callTestCase(findTestCase("Test Cases/TestCaseA1h"), [:])
The TestSuiteA1 in the High-rise project is replaced with the Controller TestCaseC1 in the Low-rise project. The TestCaseC1 is functionally equivalent to the TestSuiteA1.
Now, the Low-rise project has only a single TestSuite named TestSuiteC. In the scope of TestSuiteC, all of GlobalVariables are shared. The TestCaseA1g updates a GlobalVariable.X, which the following TestCaseB3q can easily refer to. Our problem is solved!
I would recommend the Low-rise project structure to those who struggle with the problem that Global Variables can not be shared across the boundary of Test Suite.
You can reform your High-rise project into a Low-rise project using the ordinary Katalon features; you do not have to write custom codes to read/write JSON files. Easier, isn’t it?