🎀Parameterization

Parametrization in API testing refers to the practice of using parameters or variables to make API requests and responses more flexible, reusable, and versatile.

It involves replacing specific values in API requests and responses with variables, which can be dynamically populated with different values during testing or execution. Parametrization enhances the flexibility and adaptability of your tests, allowing you to test various scenarios using a single set of test cases.

Contents


Create a Parameterized API:

In this guide, you'll learn how to perform parameterized API testing.

Step-1: Navigate to Functional Testing.

Step-2: Build a Test Script.

Step-3: Switch "Make API Parameterized" switch to on.

ParameteriedToggle
  • This toggle is disabled if any of the following is true:

    • Database Assertion is on.

Step-4: After that, make sure to save the test and then click the Parameter button at the top-right and then Parameterized popup will get displayed.

ParameteriedButton

Step-5: Then click on the Download JSON or Download Excel or Download XML button to download file.

DownloadTemplate

Note :

  • For SOAP API, Download XML will be displayed.

  • For REST API, Download JSON will be displayed.

  • For SOAP, GraphQL & REST API, Download Excel will be available.

Step-6: After downloading file open that file.

  • Now fill the value in fields

    Template

Step-7: Now save the file and Upload template by clicking on the Browse button.

BrowseTemplate

Step-8: After browsing the template, click the Submit button to upload template. Now we are all good to run the API Test.

SumbitTemplate

Note :

  • If scripts are parameterized in functional or performance or API process tests, make sure to save script once before downloading parameterized file.


Execution & Reports

Ensure the tests have been saved before execution.

Step-1: Click the Play button at the top-right to execute this parameterized API test.

RunTest

Step-2: Navigate to the reports by clicking the "Reports" button at the top-right as well and go to the "Test Result" tab.

Step-3: Find the test at the top, click View Details.

ViewDetails
  • Multiple reports are available on this page for each test case identified in the parameterization file as

  • Test -1

  • Test -2


Make individual field as parameterized

Parameterizing Specific Fields in the Request Body

Instead of parameterizing the entire request body, users can now choose to parameterize individual fields.

How to Use This Feature:

Step-1: Enable Make API Parameterized from the Info tab.

Step-2: Go to the Body tab and toggle on Parameterize Specific Field.

Step-3: Provide a Variable Name that will be used for the specific field you want to parameterize.

Replace the actual value in the request body with the following format:

Body field Parameterize

Step-4: Download the parameterized file. This file will contain the fields that are parameterized.

Step-5: Now, fill in the appropriate values for each field in the downloaded file. Once done, upload the updated file back and execute the API.

You should now see that the variable values are correctly replaced in the execution results.

In addition, the following fields can also be parameterized:

  • Headers

  • Path Parameters

  • Query Parameters

  • Assertion on Headers

  • JSON Path assertion

  • Schema Validation

Let’s see how it works!!!

Step 1: First, toggle on Make API parameterized from the info tab to use this feature.

Info

Step 2: Then, go to the Header & Params tab.

Header&Param

Step 3: In this tab go to the Header or Path parameters or Query parameters, there’ll be one column as Parameterized.

PathParam&Param

Step-4: After that, make sure to save the test and then click the Parameter button at the top-right and then Parameterized popup will get displayed.

ParameteriedButton

Step-5: Then click on the Download JSON or Download Excel or Download XML button to download file.

DownloadTemplate

Step-6: After downloading file open that file.

  • Now fill the value in fields

    Template

Step-7: Now save the file and Upload template by clicking on the Browse button.

Step-8: After browsing the template, click the Submit button to upload template. Now we are all good to run the API Test.

SumbitTemplate

Step-9: Ensure the tests have been saved before execution. And click the Play button.

  • Navigate to the reports by clicking the "Reports" button at the top-right as well and go to the "Test Result" tab.

  • Find the test at the top, click View Details.

ViewDetails
  • Multiple reports are available on this page for each test case identified in the parameterization file as

    • Test -1

    • Test -2

    • Test -3


Sample XML Template

Sample XML Template

XML Template

Sample XML Template when individual field as parameterized:

XML Template


Performance Parameterzied API

  • Before performing parameterized API testing, create a script under performance testing suite.

  • Navigate to the reports by clicking the Reports button at the top-right and find the test at the top, click View Details.

    Report
  • All the parameterized testcases will be listed as below mentioned. Click on View Details to see result of respective testcase of parameterized API.

    Report
  • Respective testcase's result would be displayed as :

    Result
    Result
    AdvanceReport
  • To check the result of next textcase, click on Go back and follow the above mentioned procedure.


Last updated