Skip to main content

Test Case Variables

Instead of running test case with hard-coded values, you can run Test Case Variables in Katalon Studio to parameterize your test case or call that test case with different inputs.

Before you start, let’s take a look at the example of test case with hard-coded values:

String employee = 'John'
String department = 'Marketing'

println "${employee} - ${department}"

Manage Test Case Variables

In this example, we want to pass variables to the following statement:

println "${employee} - ${department}"

In the Variables tab of the Test Case Editor:

  1. To add variable using grid view, switch to Variables tab of your Test Case.
  2. Then click Add. A new row is added to the variable list.
  3. Input variables.
    Note:
    • Remember to save the test case once done.



The result after running the test case with variables will be the same with hard-coded values:



View and declare variables in Script Mode

Switch to Variable (Script Mode) tab, Katalon Studio will display a Script Editor with XML format. For example:



Call Test Case with variables

  1. Open a Test Case in Manual view, then click Add and select option Call Test Case.

  2. The Test Case Browser dialog which shows all existing test cases within the project will be displayed. Select the test case to be called and click OK.

    In the following example, we call the Test Case with variables test case.



  3. A Call Test Case step will be added with the selected test case above as its target.call test case with variables





    The result after running the test case will be displayed as below:



Call Test Case in Script mode

In Script tab, the callTestCase method allows users to make a call to another test case. Refer to the following example:

WebUI.callTestCase(findTestCase('Data-driven Testing/Test Case with variables'), [('employee') : 'John', ('department') : 'Marketing', ('position') : 'Manager'], FailureHandling.STOP_ON_FAILURE)