Test Suite - Script Mode - set up method - how to pass common data value

Hello Community,

I have a Katalon test suite where I have added multiple test cases.

Now I have some general common setup script which I wanted to get executed as part of before suite . I know I can add the same script in setUp() method of the suite.

I may be calling an existing test case there in the setUp() method to make those steps possible.

This test case has some variables and I do not want to hard code the test data value there in the setUp().
I want to pass test data value to the setUp() method of suite

How this is possible ?

I know if the test case is part of test suite, we do data binding and the variables in the testcase gets replaced by the value we pass. but do not know how we can bind data at the setUp() method of test suite.

I also know that, in the setUp() method of test suite we can retrieve the Global variables values. I do not want to create gloabl variables for this.

May be the solution is already there. I do not know
Can you please throw some light here


Could you share the code?
Or you could create a psuedo code which illustrates your idea and share it.
Without sharing some code, it is very difficult to make appropriate suggestion how to write codes.

sure @kazurayam
Please see the below code which is present in the setUp() method of test suite.
I am simply using callTestCase and re-using a testcase to achive the workflow.

as you can see there are 2 variables present in the test case which need to be replaced with actual value at run time. They are testCompany and menuPath

when this is present in the test suite, i can easily do a data binding and pass data from a excel file etc.
But when this is present in setUp() method of test suite , which is expected to be run once before the test suite is triggered, i do not know how to bind data and supply here.

if those data are defined as Global variable, I can easily do it . But with out Global variable any other option ?

@SetUp(skipped = false) // Please change skipped to be false to activate this method.
def setUp() {

WebUI.callTestCase(findTestCase(‚ÄėHome/searchCompany‚Äô), [(‚ÄėtestCompany‚Äô) : testCompany], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‚ÄėMenu/NavigateToMenu‚Äô), [(‚ÄėmenuPath‚Äô) : menuPath], FailureHandling.STOP_ON_FAILURE)

one way i found is using TestDataFactory in script

some thing like below

TestData commonData = TestDataFactory.findTestData(‚Äúdata1/Company‚ÄĚ);
String company = commonData.getValue(1, 1);
String menu = commonData.getValue(2, 1);

then pass these

If you know any better solution, please let me know

How many pairs of (company, menu) do you have? 1? or many?

If many, do you want to iterate over the all pairs?

If you want to iterate over the all pairs of (company, menu), the def setUp() method of a Test Suite would not be appropriate place where you perform that iteration.

If I am to implement this, I would rather add a new test case named ‚ÄúController‚ÄĚ where I would write the following lines:

 * Test Cases/Controller
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import com.kms.katalon.core.testData.TestData

TestData companyList = TestDataFactory.findTestData("data1/Company")
for (int i = 1; i < companyList.getRowNumbers(); i++) {
    def name = companyList.getValue("name", i).trim()
    def menu = companyList.getValue("menu", i).trim()
    // call common setup scripts
    WebUI.callTestCase(findTestCase(‚ÄėHome/searchCompany‚Äô),[(‚ÄėtestCompany‚Äô) : name],
    WebUI.callTestCase(findTestCase(‚ÄėMenu/NavigateToMenu‚Äô), [(‚ÄėmenuPath‚Äô) : menu],
    // and call other business scripts

And your test suite calls the ‚ÄúController‚ÄĚ testcase only. Its @SetUp method has nothing to do.

1 Like

Thank you @kazurayam it makes sense to me :+1:

Warm Regards