Skip to main content

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.

Note:
  • 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:

  1. Log in to the application under test (AUT) - Katalon CURA Healthcare Service: https://katalon-demo-cura.herokuapp.com.
  2. Book an appointment by filling in a form with visit date and comment.
  3. 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:

  1. Record the test case: we record the test case to log in and book an appointment manually.
  2. 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:

  1. In Katalon Recorder, create a new test case, then click on the Record button to start recording.

    Katalon Recorder new test case

  2. In an active browser tab, navigate to the AUT.

    Here the URL for the AUT is https://katalon-demo-cura.herokuapp.com.

    Katalon Recorder AUT overview

  3. Log in to the AUT.

    On the top-right corner of the homepage, click on the menu button and select Login.

    Katalon Recorder AUT login button

    On the opened Login page, type in the sample username and password, then click Login.

    Katalon Recorder AUT login page

  4. On the Make Appointment page, input the visit date and comment, then click Book Appointment.

    Katalon Recorder AUT make appointment page

  5. Log out of the AUT. Click on the menu button and select Logout.

    Katalon Recorder AUT logout button

  6. In Katalon Recorder, click on the Stop button to stop the recording

The recorded test case is as follows:

Katalon Recorder recorded test case

Implement data-driven testing

In Katalon Recorder, there are three steps to implement DDT in a test case:

  1. Prepare the data file.
  2. Add the data file to your workspace.
  3. 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:

Katalon Recorder recorded test case

This CSV data file has a column named "Comment" that contains appointment comments.

Add the data file to the workspace

Follow these steps:

  1. In the Workspace sidebar, click on the Open a Data File button in the Test Data section.

    Katalon Recorder add test data

  2. In the opened file explorer, select the CSV file.

    Katalon Recorder select the CSV file

  3. 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:

  1. Select the data file. Right-click on the data file and select Use this in a test case.

    Katalon Recorder use test data file

  2. 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.

    Katalon Recorder select test case

  3. 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.

    Katalon Recorder configure comment variable

  4. Verify that the values in the test case are replaced with the correct variable.

    Katalon Recorder configure comment variable

  5. 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.

    Katalon Recorder DDT results

See also: