Skip to main content

Data-driven testing at test case level

Important:
  • An active Katalon Studio Enterprise (KSE) license. To learn more about activating your license, you can refer to this document: Activate Katalon license.

Data-driven testing (DDT) at test case level allows you to add data files and manage data binding at test case level. It helps you keep the data binding in the test case independent, regardless of the test suites it is added to.

This article demonstrates how to:
  • Perform data binding at test case level
  • Execute that test case in a test suite
  • View data-driven test reports

Bind data at the test case level

Before you perform data binding at the test case level, you need to prepare test data files and test case variables.

Create a test data file

To create a test data file, go to File > New > Test Data. Katalon Studio allows you to use external or internal data sources for test execution. To learn more about creating new data files, refer to: Manage Test Data.

Create test case variables

  1. Go to File > New > Test Case to create a new test case.
  2. Go to the Script view and input the following script:
    println "${employee} - ${department}"
  3. Switch to the Variables tab. Click Add, then input variables in the newly added row.
    The variables tab

Perform data binding

To perform data binding at the test case level, do as follows:
  1. Navigate to the Data Binding tab. You can see the Test Data and Variable Binding tables.
  2. In the Test Data table, click Add.
    Add data files

  3. Select the data files to use for variable binding in the Test Data Browser dialog, then click OK.
    Test Data Browser

    The selected test data files appear in the Test Data table.

    Results after adding data files

    Note:
    • If you add multiple data files, by default, Katalon defines the relationship of multiple data sources at the test case level as one-to-one relationship. To learn more about the relationship between multiple data files, see Manage test data relationship.
  4. In the Variable Binding table, do as follows:
    1. Highlight both data rows, click Set Type > Data Column.
      Set Data Type

    2. In the Test Data column, click on each row to choose the data files.
      Choose Test data for Data Type

    3. In the Value column, click on ... to specify the data field in the selected data file.
      Choose Value for Data Type

      If the variables and selected data files column headers share the same name, you can click Map All to quickly map them together.

  5. Save and run the test case. You can view the execution results in the Log Viewer.
    Results in Log Viewer

Handle data binding in called test cases

When a test case (for example, Test Case A) calls another test case (for example, Test Case B), the called test case does not automatically inherit data bindings or variable values from the main test case. To ensure Test Case B receives the appropriate data, you need to explicitly pass the variables during the call.

To pass variables, follow these steps:
  1. Define variables in the called test case.
    1. Open the called test case (Test Case B).
    2. Navigate to the Variables tab.
    3. Click Add, then define the variables required for execution. For example, create a variable named employee.
  2. Call the test case and map variables.
    1. In the main test case (Test Case A), add a Call Test Case step to invoke Test Case B. To learn how to call another test case as a test step, see Call test case.
    2. In the Manual view, click on the Input cell where [:] is shown.
    3. Map variables from the main test case to the corresponding variables in the called test case.
      For example: The employee variable in Test Case B is mapped to the employee variable from Test Case A.

    4. Click OK to save changes.

Quick tips

To simplify the variable mapping process, ensure the following option is enabled before generating new Call Test Case method:
  1. Go to Katalon Studio > Settings... > Preferences > Katalon > Test Case > Test Case Calling.
  2. Select Generate variable with the same name as the exposed variable of the called test case, then check Expose variables automatically after choosing the called test case.
  3. Click Apply and Close.

With this setting, variables in the called test case will automatically appear for mapping when adding the Call Test Case step.

Execute test suite containing test case level data binding

You can execute a test case with configured data binding regardless of the test suite data binding.
  1. Add the test case with configured data binding to a test suite.
  2. In the test suite editor, click Show Data Binding.
    Data binding section in the test suite

  3. Click on the test case, then select the Use Variables and Binding at Test Case option.
    With this option:
    • Katalon Studio will execute the test case with the test case level data binding.
    • When enabled, you can not conduct data binding at the suite test case.
    Note:
    • If your test suite has existing data configurations, switching to the Use Variables and Binding at Test Case option does not remove the pre-configured data in the suite test case.
  4. To edit the test case level data binding, click on the Test Case hyperlink.
    You are navigated to the Data Binding tab of the test case.
  5. Once finished, click Run to execute your test suite.
You've executed a test suite with a test case using data binding at test case level.

View test reports

After the test suite execution, to view your test reports, do as follows:
Go to the Reports folder in the Test Explorer panel.
Reports

Note:
  • When running a test suite that uses data binding at the test case level, the total number of executed test cases in test reports is the number of executed iterations. In the above example, we run a test case with 3 different sets of data, we can see the results of three executed test cases in the test reports.

Alternatively, you can also view your reports and details in <your-project-folder>/Reports. Katalon Studio supports exporting test reports into different formats, such as HTML, CSV, PDF, and JUnit. You can learn more about exporting reports here: Generate reports.

Reports

Was this page helpful?