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

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],
         FailureHandling.STOP_ON_FAILURE)
    WebUI.callTestCase(findTestCase(‘Menu/NavigateToMenu’), [(‘menuPath’) : menu],
        FailureHandling.STOP_ON_FAILURE)
    // and call other business scripts
    WebUI.callTestCase(findTestCase(....
    WebUI.callTestCase(findTestCase(....
}

And your test suite calls the “Controller” testcase only. Its @SetUp method has nothing to do.

1 Like