Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • request: an API request (e.g. HTTP POST on some URL, with some values)
    • authentication: authentication for the API request (e.g. HTTP basic auth, etc); can be defined at multiple levels and inherited
  • collection: a way of grouping multiple requests
  • folders within the collection: a way to better organize requests within the collection
  • variables: can be defined at multiple levels (e.g. global, collection, environment, local, ...)
  • test: a test; can be defined at request, folder or collection level
  • pre-request script: some code execute before each test; can also be defined at request, folder or collection level
  • environment: an abstraction of some test environment that describes a context for running the requests; it consists of one description plus a set of variables with their corresponding values

Implementing tests

Testing is achieved through the usage of scripts.

Tests can be implemented using Javascript and making use of Postman APIs/objects supported assisted by Chai assertions. 

One or more tests can be defined at the request level, or even at the whole collection level.

...

Variables can be defined at multiple levels and can be used to make maintenance easier; the sample applies to authentication, which can also make use of variables.

A test is defined by using "pm.test()".




Code Block
languagejs
titleexample of a test that looks at the response's HTTP status code
pm.test("response is ok", function () {
    pm.response.to.have.status(200);
});



In Postman, quoting Postman documentation, the pm object encloses all information pertaining to the script being executed and allows one to access a copy of the request being sent or the response received. It also allows one to get and set environment and global variables.

Therefore, pm can be used to access the response, to perform assertions or even to make some requests.


Integrating with Xray

Integrating with Xray, in order to have visibility of API testing results in Jira, can be done by simply submitting automation results to Xray through the REST API or by using one of the available CI/CD plugins (e.g. for Jenkins).

...

  • After importing results, you can link Test issues to existing requirements or user stories, so that you can track coverage on real-time directly on them
  • You can map Postman's environment to Xray's Test Environment concept on Test Executions if you want to have visibility of the results on a per-environment basis
  • Multiple iterations/executions can be linked to an existing Test Plan, whenever importing the results

References