SlideShare a Scribd company logo
POSTMAN
ON
STEROIDSSARA TORNINCASA @ CODERMINE
GITHUB.COM/SARASEWARD/POSTMAN-ON-STEROIDS
HTTP REQUESTS WITH A FRIENDLY UI
the dinosaur's footprints
PUBLISH
DESIGN
& MOCK
DEBUG
AUTOMATED
TESTING
DOCUMENT
MONITOR
POSTMANFUNDAMENTALS
ENVIRONMENTS
VARIABLES
COLLECTIONS
WORKSPACES
ENVIRONMENTS
SESSION VALUES: HANDLE SENSITIVE VALUES
VARIABLES
VARIABLES
Dynamic variables in the request URL / headers / body:
{{$guid}} | {{$timestamp}} | {{$randomInt}}
Read more
VARIABLE SCOPES
GLOBAL
COLLECTION
ENVIRONMENT
DATA
LOCAL
Postman On Steroids
COLLECTIONS & EXAMPLES
COLLECTIONS
Collections are groups of requests that can be run
together as a series of requests, against a
corresponding environment.
> Automate API testing
> Make better use of scripts: pass data between
requests...
> ...or build workflows that mirror your APIs' use case.
WORKSPACES
WORKSPACES
A workspace is a view of all the Postman
things you've come to use: collections,
environments, ...
> Individuals can organize their work in
personal workspaces
> Teams can collaborate in team
workspaces.
> You can share elements in multiple
workspaces at the same time.
Postman On Steroids
ROLES
COLLECTIONS TEAMS WORKSPACES
Collection
Editor
Collection
Viewer
Team
Admin
Team
Billing
Team
Developer
Workspace
Admin
Workspace
Collaborator
Roles extended | All roles
VERSION CONTROL
> Fork a collection
> Merge between forks
> Pull between forks
Read More
SCRIPTS
TESTING
PRE REQUEST SCRIPTS & TESTS
BEFORE:
PRE REQUEST SCRIPTSARE SNIPPETS OF JAVASCRIPT CODE EXECUTED BEFORE THE REQUEST IS SENT.
AFTER:
TESTSARE SNIPPETS OF JAVASCRIPT CODE EXECUTED AFTER THE REQUEST IS SENT.
Test examples
pm.test("Response is ok", function () {
//ok, success, redirection, clientError, serverError
pm.response.to.be.ok;
});
pm.test("Response can be processed by clients", function () {
pm.response.to.be.json;
pm.response.to.not.have.jsonBody("error");
});
pm.test('There is at least one contract', function(){
var data = pm.response.json();
pm.expect(data.contracts.length).to.be.above(0);
})
pm.test('All contracts have one line', function(){
var data = pm.response.json();
for (i = 0; i < data.contracts.length; i++){
contract = data.contracts[i];
pm.expect(contract.lines.length).to.eql(1);
}
})
SCRIPT SCOPES
Postman On Steroids
I love inserting data manually
— Nobody, ever
PASS DATA BETWEEN REQUESTS
pm.test("Response contains customerId and userId", function () {
pm.response.to.have.jsonBody("customerId");
pm.response.to.have.jsonBody("userId");
});
//Set global variable
var data = pm.response.json();
pm.environment.set("customerId", data.customerId);
console.log("Env customerId id is " + pm.environment.get("customerId"));
pm.environment.set("userId", data.userId);
console.log("Env userId id is " + pm.environment.get("userId"));
Pre request script...
schema = {
"properties": {
"customerId": {
"type": "string"
},
"jsessionId": {
"type": "string"
},
"userId": {
"type": "integer"
}
},
"required": [
"customerId",
"userId",
]
};
...Test
// Request MUST define a JSON schema under the name "schema"
// in its pre-requests scripts
pm.test('Schema is valid', function() {
var result=tv4.validateResult(pm.response.json(), schema);
if(!result.valid){
console.log(result);
}
pm.expect(result.valid).to.be.true;
});
COLLECTION RUNNERS
MONITORS
NEWMAN
COLLECTION RUNNERS
COLLECTION RUNNERS
Collection runners send all requests in one collection one
after another, with a specific:
> Environment
> Number of iterations
> Delay between requests
> Log level
> Data file
READ DATA FROM FILES
Override current variables with values defined in a .json
or .csv file.
[
{
"username":"purpleurkle",
"password":"waldos",
"lineId": "1234567890",
"contractId": "1234567890cc",
"useDataFile": true
}
]
Read More
WORKFLOWS
WORKFLOWS
Build and test workflows that mirror your actual use
case of APIs.
Read more
//Set next request
postman.setNextRequest("menu web (flows)")
//End collection run
postman.setNextRequest(null)
MONITORS
MONITORS
Monitors run a collection periodically, with a specific:
> Environment
> Run frequency
> Region
> Request timeout/delay
> Email notifications on failure
CD/CI INTEGRATION
WITH NEWMAN
NEWMAN
Newman is a command line Collection Runner for Postman.
You can configure continuous integration tools to
respond to Newman's exit status codes and
correspondingly pass or fail a build.
Read More | Newman docs on Github
dl npm @ https://nodejs.org/en/download/package-manager/
or run $ brew install node
$ npm install -g newman
$
$ newman run examples/sample-collection.json
$
$ newman run https://www.getpostman.com/collections/{{id}}
$
$ newman run -h
! Status Code Test
GET https://echo.getpostman.com/status/404 [404 Not Found, 534B, 1551ms]
1. response code is 200
"#########################$##########$##########%
& & executed & failed &
'#########################(##########(##########)
& iterations & 1 & 0 &
'#########################(##########(##########)
& requests & 1 & 0 &
'#########################(##########(##########)
& test-scripts & 1 & 0 &
'#########################(##########(##########)
& prerequest-scripts & 0 & 0 &
'#########################(##########(##########)
& assertions & 1 & 1 &
'#########################*##########*##########)
& total run duration: 1917ms &
'###############################################)
& total data received: 14B (approx) &
'###############################################)
& average response time: 1411ms &
+###############################################,
# failure detail
1. AssertionFai… response code is 200
at assertion:1 in test-script
inside "Status Code Test" of "Example Collection with
Failing Tests"
REPORTERS
Reporters are node modules that provide information
about the collection run in a specific format.
$ newman run examples/sample-collection.json -r cli, json
$ newman run examples/sample-collection.json --reporters json
cli [default] json
junit external (HTML)
Custom (Read more)
newman run <collection-file-source> [options]
$-e <source>, -environment<source>
$-g <source>, --globals <source>
$-d <source>, --iteration-data <source>
$-n <number>, --iteration-count <number>
$--folder <name>
...And More
THERE'S MORE!
DOCUMENTATION
Read more | Postman On Steroids docs
MOCK SERVER
Mock with examples | Mock with API | Matching algorithm | Read more
INTEGRATIONS
Read more
> Use Postman as proxy
> Generate code snippets
> Enterprise Audit logs
> Enterprise SSO
Pricing
DOCUMENTATION
Concepts
Blog
Youtube channel
Postman On Steroids
THANKYOU
github.com/saraseward/postman-on-steroids | Pictures: learning.getpostman.com

More Related Content

Postman On Steroids