Skip to content

Latest commit

 

History

History
112 lines (65 loc) · 4.47 KB

POSTMAN.md

File metadata and controls

112 lines (65 loc) · 4.47 KB

Using Postman

Setup Postman

First install Postman from here.

Setup Project Workspace

Open Postman and start by creating a new Personal Workspace by clicking the drop-down at the top of the screen.

Screen-shot - Create New Workspace

Import Workspace Global variables

Once this is setup, import the global variables by clicking the "Import" button in the top left corner. Under the "Import File" tab, you can either browse to the globals file or drag it into the box. You need to import the file - '[ROOT]/tests/newman/project_globals_config.postman_globals.json'

Screen-shot - Importing globals file to workspace

Importing an existing collection of tests

Editing a "collection" involves importing the collection into postman along with the associated environment if it exists. This is done in the same way as descried above for importing workspace globals.

Click the "Import" button in the top left corner. Under the "Import File" tab, you can either browse to the collection file or drag it into the box. At this point also import any associated environment files.

Screen-shot - Importing collections and environments

Note: When editing a collection, ensure you have the same environment selected while sending the requests.

Screen-shot - Setting environment to collection

Some rules for formatting your request

A collection will have one or more requests, these are displayed on the left-hand side.

When formatting your requests, it is best to set values as variables and then apply them to the request by calling the variable inside '{{VARIABLE_NAME}}'.

It is also important to set the base url as a the global variable '{{BASE_URL}}'. Using these variables allows us to modify the request dynamically when executed with newman so it is relevant to the environment that it is executed against.

Screen-shot - Using variables in the request

Adding tests to a collection's request

The collection tests are edited in the "Tests" tab. These tests are written in javascript.

Screen-shot - Writing tests for a collection

For more detailed information on how to do this, take a look at the Postman docs on writing test scripts

Creating a new collection of tests

To create a new test in Postman, click the "New Collection" button.

Collection names must NOT have any spaces or special characters. The name of the collection will be exported to the collection file's name.

In the below image example the collection is named "SomeTestCollection". This will later be exported to: "[ROOT]/tests/newman/tests/[NEWMAN_GROUP]/SomeTestCollection.postman_collection.json"

Screen-shot - Creating a new collection

Creating a new environment for a collection

To add a new collection environment, click the "Manage Environments" button (has a cog icon) in the top right of the screen. Then click the orange "Add" button.

Screen-shot - Adding collection environment

Environments need to be named the same as the collection for which they are created. For example, the above collection was named "SomeTestCollection". Then an associated environment will also be called "SomeTestCollection". When the environment is exported, it will share a common name with the collection. In this way they are linked during execution with the nt-run script.

Exporting a collection

To export a collection, lick the three dots on the collection, then click "Export"

Screen-shot - Export collections

Collection files are exported to a "test group" folder. "[ROOT]/tests/newman/tests/[NEWMAN_GROUP]/SomeTestCollection.postman_collection.json"

Exporting an environment

To export a collection environment, click the "Manage Environments" button (has a cog icon) in the top right of the screen. Each environment has a download button. Click the relevant environment's download button and save it to the same folder as it's collection. Eg: "[ROOT]/tests/newman/tests/[NEWMAN_GROUP]/SomeTestCollection.postman_environment.json"

Screen-shot - Export environments