Enhanced Variable Binding

Estimated reading time: 2 minutes

Starting from version 6.3.0, variable binding can be configured to read test data values as the intended data types. This feature is only applicable for Test data of type Excel and Database.

User can enable this feature to obtain old variable binding behaviors. Old test data will continue to be read as string to ensure that we don't break existing test cases.

In this example, we will create a test suite and a test case with variables. booleanVar is a test case variable of type Boolean. numberVar is a test case variable of type Number. stringVar is a test case variable of type String.

Boolean Integer String
TRUE 1 one
FALSE 2 zero

Create the following custom keyword TestDataKeyword:

public class testdata {
	
	public static void printString(String str) {
		println str;
	}
	
	public static void printInt(BigDecimal integer) {
		println integer;
	}
	
	public static void printBoolean(boolean bool) {
		println bool;
	}
	
}

Use them in the test case Sample Test Case as followed:

TestDataKeyword.takeBooleanAndPrint(booleanVar);
TestDataKeyword.takeNumberAndPrint(numberVar);
TestDataKeyword.takeStringAndPrint(stringVar);

where booleanVar, numberVar, stringVar are test case variables.

Variable binding for Test Data with option bind into test case as string enabled

Create a Test Data with option bind into test case as string enabled and with the data provided above.

Follow the steps in this document and run the test case. Then we will have the result as below:

The test suite should fail because the first keyword function takeBooleanAndPrint does not expect a String, but because bind into test case as string is enabled so test data values are read as string.

Variable binding for Test Data with option bind into test case as string disabled

Create a Sample Test Data with option bind into test case as string disabled.

Repeat the steps same as above. Then we will have the result as below:

The test suite should pass because bind into test case as string is disabled so test data values are read as-is and all keyword functions receive their expected data types.

Quick tip

To push customizability further, Katalon now supports an annotation called BeforeTestDataBindToTestCase which allows the annotated functions to operate on Test Data variables before they are bound into test cases.

Prior to Katalon 6.3, you would have to compile another set of Test Data for each requirement. Increasingly varied requirements would then further complicate Test Data management.

Starting from version 6.3, you will need one raw Test Data file and then define the rules of transformation in different functions using the new annotation. With this feature, deciding how Test Data variables will be used occurs at run-time.

User Contributed Notes