Skip to main content

Data-driven testing best practices

Last updated: November 2026

This document explains the best practices when working with data-driven testing.

Requirements
  • Starting with Katalon Studio 11.7.0, data-driven test execution requires a paid plan. Free-plan users cannot run data-driven tests, including Test Suite Collections in which any suite uses data binding.
  • A Test Data file, such as an Excel or CSV file with sample credentials.
  • Captured Test Objects for the login form's username, password, and login button.

Data-driven testing works well when a test needs to use multiple data sources, such as different login credentials. Design one data-driven login test case that reads values from an external data source, such as an Excel or CSV file, then run it with rows for valid users, invalid credentials, and locked accounts.

By parameterizing the username, password, and expected outcome (SUCCESS, FAILURE, or ACCOUNT_LOCKED), you can avoid creating separate test cases for each scenario, improve positive and negative coverage, and add or update user types by editing the test data file rather than the test logic.

Get Started​

The following example uses synthetic data:

usernamepasswordexpectedResult
qa.user@example.testsample-passwordSUCCESS
invalid.user@example.testsample-passwordFAILURE
locked.user@example.testsample-passwordACCOUNT_LOCKED

Step 1: Create a test data file from the test data sheet​

  1. Go to File > New > Test Data.

    Data-Driven Testing best practices image 3
  2. Name the file LoginCredentials.

  3. Select Excel File or CSV File.

  4. Browse to and select your file.

  5. Select Use first row as header.

  6. Click OK, then save the file.

Step 2: Create a test case with variables​

  1. Go to File > New > Test Case and name the test case Login_DDT.
  2. Click the Variables tab.
  3. Add the following variables:
NameTypeDefault
usernameStringqa.user@example.test
passwordStringsample-password
expectedResultStringSUCCESS

Step 3: Write the script for the test case​

The following example navigates to a login site, enters the credentials, and validates the outcome specified in the test data sheet. Replace the example URL and Test Object paths with those for your application, and open a browser before running these steps.

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

// Navigate to the login page
WebUI.navigateToUrl('https://example.com/login')

// Fill in the login form with variables
WebUI.setText(findTestObject('Object Repository/Username_Input'), username)
WebUI.setText(findTestObject('Object Repository/Password_Input'), password)
WebUI.click(findTestObject('Object Repository/Login_Button'))

// Verify the result based on the expected outcome
if (expectedResult == 'SUCCESS') {
WebUI.verifyElementPresent(findTestObject('Object Repository/Dashboard_Page'), 5)
println("✓ Login successful for: ${username}")
} else if (expectedResult == 'FAILURE') {
WebUI.verifyElementPresent(findTestObject('Object Repository/ErrorMessage'), 5)
println("✓ Error handling verified for: ${username}")
} else if (expectedResult == 'ACCOUNT_LOCKED') {
WebUI.verifyElementPresent(findTestObject('Object Repository/LockedMessage'), 5)
println("✓ Account locked message verified for: ${username}")
}

Step 4: Configure data binding​

  1. In the test case, click the Data Binding tab.

  2. Click Add in the Test Data section.

  3. Select the LoginCredentials file.

  4. In the Variable Binding section, map each variable to its matching column:

    • username → username
    • password → password
    • expectedResult → expectedResult
    Data-Driven Testing best practices image 2
  5. Click Map All if the column names match the variable names.

    Data-Driven Testing best practices image 1

Step 5: Execute the test case​

  1. Click Run.
  2. Katalon Studio executes the test case once for each data row (three iterations).
  3. View the results in Log Viewer. The following output is illustrative; actual timing and layout depend on your run:
Test Cases/Login_DDT (2.5s)
├── Iteration 1 - username=qa.user@example.test, expectedResult=SUCCESS (0.6s) - PASSED
├── Iteration 2 - username=invalid.user@example.test, expectedResult=FAILURE (0.7s) - PASSED
└── Iteration 3 - username=locked.user@example.test, expectedResult=ACCOUNT_LOCKED (0.6s) - PASSED

Step 6: Check for errors​

// Validate data before execution
if (username == null || username.isEmpty()) {
throw new Exception("Username cannot be empty")
}

if (!(username ==~ /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)) {
throw new Exception("Invalid email format: ${username}")
}

if (password == null || password.isEmpty()) {
throw new Exception("Password cannot be empty")
}

println("✓ Data validation passed for: ${username}")

Common pitfalls to avoid​

When designing variables and referencing external data files for DDT, follow clean-code naming conventions:

  1. Global variables: Use the uppercase string convention when declaring global variables.
  2. Local/test case variables: Use camel case when declaring local or test case variables.
  3. Variable naming: Avoid meaningless variable names and keywords. Use appropriate comments or descriptions to explain a variable's purpose.
  4. Data file references: Select Use relative path in the file information settings when referencing data files.

Scaling recommendations​

  • Organize data files by feature (for example, Authentication/ and Checkout/).
  • Use database data sources for large datasets (100 or more rows).
  • Integrate DDT into CI/CD to run tests automatically.
  • Use Katalon True for centralized reporting.
Was this page helpful?