Skip to content

Postman Integration and Overrides

Julio Zevallos edited this page May 17, 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 (Of Postman v2.0.0 , and v2.1.0). 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.requestname or servicename.foldername.requestname from models (Spaces are supported in folder names and request names), 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 columns (partial set):

Step Action Target Input
omdb call serviceCall omdb.Wall-E GET
omdb call2 serviceCall omdb.othermovies.The Lion King GET
omdb call3 serviceCall omdb.othermovies.scarymovies.Shaun of the Dead GET

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 "Wall-E" as the intended request name.
  • If the desired request is in a collection folder, such as omdb.othermovies.The Lion King , will search for the folder "othermovies", then look for the request "The Lion King" in there.
  • Note that we support recursive folders. Example, the Shaun of the Dead entry.

Postman collection path: "example_usage/models/omdb/postman_collection.json"

  • It then looks at the Overrides value, and replaces the values found in double brackets "{{valueToUse}}" 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.