Test Data Parameterization

You are here:
  • Main
  • Test Data Parameterization
< All Topics

The Test Data Parameterization functionality allows testers to execute the same test case multiple times with different data inputs without having to create duplicate test cases. It replaces the traditional practice of entering hard-coded input values with parameters. Test Data parameterization allows QA teams to store reusable test data in one centralized location, Import existing parameters, data sets, and share data across projects. Parameterization of test data is one of the ways to make your tests consistent and manageable. You can create automated data-driven tests quickly using Test Data Parameterization in TestGrid.

In TestGrid if you want to keep your test data separate from the test case then you have to follow a 3 step process.

    1. Create a CSV file with the test data.
    2. Convert the CSV file into the URL returning JSON data.
    3. Use the JSON URL to access data inside the test case.

1. Create a CSV file with the test data.

      • You have to store your input data in a CSV file, where the first row should contain the title or description for the Entity. From the second row onwards you can write values for the Entity.

For example:

CityName,CountryName

Atlanta,Georgia

Savannah,Georgia

Norcross,Georgia

2. Convert the CSV file into the URL returning JSON data.

    • Open the url (https://www.testgrid.io/csv-to-json) in the browser.
    • Drop or browse the CSV file into the “DROP HERE” section. There is also an option to write/paste the CSV text.

    • Click on the Convert button after uploading the CSV file.
    • You will be redirected to the new URL with a JSON response.  (i.e. https://www.testgrid.io/json/20201120/SidbP4.json)
    • Copy the URL link from the browser. This URL will be used in the test case to access data.

3.Use the Json URL to access data inside the test case.

    • First, we need to create a variable of datatype JSON to store our response from the URL we got in step 2.

    • So here the variable CSVData contains the whole response from the JSON URL.
    • To get individual value from the whole response we need to declare individual variables and then assign them value using Jsonpath.

    • Here we have declared the “firstCity” named string variable and assigned the value of first city name from JSON response using Jsonpath “$.records[0].CityName”.
    • Now we can use this “firstCity” variable into Type Action.

    • Based on our example it will read the first city name (“Atlanta”) from the response and type it in the SearchLocation EditText field. 
    • To iterate over a list of City values, we need to create a Jsonpath with some integer variable whose value keeps increasing every iteration. We can do that as follows:

During the run time we can see the CityName variable getting different values we provided. We can see value in Type action.

Modifying the input data in the existing JSON URL:

    • If we need to update the input data in the JSON URL, 
      1. We have to modify the CSV file as per requirements.
      2. Open the CSV2Json Converter (https://www.testgrid.io/csv-to-json) in the browser.
      3. We have to paste the JSON URL that we want to modify in the “Update Existing URL” text field
      4. Upload the modified CSV file and click on the Convert button.
      5. Now, the same URL will provide you the updated JSON response.
Table of Contents