How to implement data-driven testing in a test case with Katalon Recorder
Whenever you want to execute a test case repeatedly with different data, you can implement data-driven testing (DDT). Katalon Recorder facilitates DDT with DDT commands and several data formats. See: Data-driven testing in Katalon Recorder.
This tutorial shows you how to implement DDT in a test case.
- To use the sample project of this tutorial, navigate toActions > Sample Projects, then add the Implement data-driven testingproject.
Test case scenario
In our example, we follow the test case with the scenario "log in and book a healthcare appointment," which consists of these steps:
- Log in to the application under test (AUT) - Katalon CURA Healthcare Service:
https://katalon-demo-cura.herokuapp.com
. - Book an appointment by filling in a form with visit date and comment.
- Log out.
To demonstrate implementing DDT in Katalon Recorder, we create a test case that uses data from a CSV file to book three appointments. The process is as follows:
- Record the test case: we record the test case to log in and book an appointment manually.
- Implement DDT in the test case: we bind the test case with a data file and modify it with DDT commands.
Record the test case
We record a test case according to the presented scenario.
Follow these steps:
-
In Katalon Recorder, create a new test case, then click on the Record button to start recording.
-
In an active browser tab, navigate to the AUT.
Here the URL for the AUT is
https://katalon-demo-cura.herokuapp.com
.
-
Log in to the AUT.
On the top-right corner of the homepage, click on the menu button and select Login.
On the opened Login page, type in the sample username and password, then click Login.
-
On the Make Appointment page, input the visit date and comment, then click Book Appointment.
-
Log out of the AUT. Click on the menu button and select Logout.
-
In Katalon Recorder, click on the Stop button to stop the recording
The recorded test case is as follows:
Implement data-driven testing
In Katalon Recorder, there are three steps to implement DDT in a test case:
- Prepare the data file.
- Add the data file to your workspace.
- Configure data-driven commands and variables in the test case to use data from the data file.
Prepare the data file
Katalon Recorder supports two data file formats: CSV and JSON. To learn more about the supported formats and their specifications, refer to this document: Data-driven testing in Katalon Recorder.
In our example, we use the following CSV file:
This CSV data file has a column named "Comment" that contains appointment comments.
Add the data file to the workspace
Follow these steps:
-
In the Workspace sidebar, click on the Open a Data File button in the Test Data section.
-
In the opened file explorer, select the CSV file.
-
Katalon Recorder should display the selected file under the Test Data section.
Configure data-driven commands and variables in the test case
Katalon Recorder also provides a simple user interface to configure data-driven commands and variables.
Follow these steps:
-
Select the data file. Right-click on the data file and select Use this in a test case.
-
Select the test case. In the displayed menu, select the desired test case. Click Next to continue.
Here we select the test case that we previously recorded.
-
Use the data from the data file. In the displayed test case, select the commands and specify the desired variables. Click Add when done.
Katalon Recorder specifies a variable using the
${<variable_name>}
syntax as a placeholder in the Value field. When executing the test case, Katalon Recorder expands the variable into its value.We want to use the comments from the CSV file, so we replace the current comment text with the
Comment
variable.
-
Verify that the values in the test case are replaced with the correct variable.
-
Play the test case and verify the results in the Log view. The log message should indicate that Katalon Recorder expands the specified variables into test data.
The Katalon Academy course: Data-Driven Testing with Katalon Recorder.