Skip to main content

Test case variables

Test case variables are variables defined in a test case. In Katalon Studio, test case variables are defined in the Variables tab.

Instead of running test case with hard-coded values, you can create test case variables and dynamically run the test case with different inputs.

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 and save the test case.



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 a test case with variables

The following is an example of dynamically calling a test case with a set of values.

  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)