Skip to content

Postman Integration and Overrides

mikepoz59 edited this page May 10, 2019 · 25 revisions

This page will give you the understanding and implementation of postman collection for API testing.

Using postman collection for API testing :

  • Create an API postman collection in standard format of postman. Recommended is to export the API request format as collection from postman.
  • Create a folder with the service name with in the models folder and keep the collection inside of the service.
  • Create a test suite (.xlsx) with in the suites folder and update the test data t- tab with the test steps.
  • In test steps update the Action as ServiceCall, Target as servicename.path from models, Input as the API calling method POST or GET or PUT or DELETE or any other, rest of the fields can be more generic.
  • Go to exmaple_usage/bin in command prompt and execute as run.bat <testsuitename.xlsx>
  • Verify the logs and extended report for the test results.

From the sampletest.xlsx "t-omdb&imdb" tab, line 3 you will find the following:

Step Action Target Input Overrides omdb call serviceCall sample.api.create GET endpoint::host::{{omdbhost}}::path::{{omdbpath}} (plus more columns)

Sample Test spreadsheet path: "example_usage/suites/testdata.xlsx"

This entry uses the Target value, find the "sample" postman collection, and reads the URL, looking for "api/create" as the intended URL target.
Postman collection path: "example_usage/models/sample/postman_collection.json"

It then looks at the Overrides value, and replaces the values found in double brackets "{{value}}" with the corresponding value found in the testdata.xlsx spreadsheet.
Test data spreadsheet path: "example_usage/testdata/testdata.xlsx"

Overriding or assigning values for variable in postman collection (set request body):

This feature can be used to parse test data based on environment (Dev/Prod) without changing the postman collection.

  • Create an API postman collection in standard format of postman and key-values should be as variables <{{varname}}>. Recommended is to export the API request format as collection from postman.
  • Create a folder with the service name with in the models folder and keep the collection inside of the service.
  • Create a test suite (.xlsx) with in the suites folder and update the test data t- tab with the test steps.
  • In test steps update the Action as ServiceCall, Target as servicename.path from models, Input as the API calling method POST or GET or PUT or DELETE or any other and Overrides column should have values for variables in postman collection like <bodytemplate::key-var-value::key-var-value-toReplace>, rest of the fields can be more generic.
  • Multiple Overides can be accepted like <bodytemplate::key-var-value1::key-var-value-toReplace1::key-var-value2::key-var-value-toReplace2>.
  • Go to exmaple_usage/bin in command prompt and execute as run.bat <testsuitename.xlsx>
  • Verify the logs and extended report for the test results.

Override the API endpoint for postman and swagger (set endpoint):

This feature can be used when the user wants to in different environments with out changing the postman collection.

  • Create a folder with the service name with in the models folder and keep the collection inside of the service.
  • Create a test suite (.xlsx) with in the suites folder and update the test data t- tab with the test steps.
  • Or user can proceed with existing postman collection if postman collection already exists.
  • In test steps update the Action as ServiceCall, Target as servicename.path from models, Input as the API calling method POST or GET or PUT or DELETE or any other and Overrides column should have values like <endpoint::host::<overridehost>
  • Multiple Overides can be accepted like <endpoint::host::<overridehost>::protocol::<overrideprotocol>::path::<overridepath>.
  • Other way to override is to accept values from environment specific data sheet or default data sheet. Keep the key-name as {{keyname}} and update data sheet with {{keyname}} and {{keyvalue}}. Multiple overrides can accepted.
  • Go to exmaple_usage/bin in command prompt and execute as run.bat <testsuitename.xlsx>
  • Verify the logs and extended report for the test results.