TEST AUTOMATION & DIGITAL QA SUMMIT
#TAS19
Auckland
November 7th, 2019
TESTINGMIND
www.testingmind.com
Postman live demo &�Postman object model
by Vincent Dirks
TESTINGMIND
www.testingmind.com
Postman object models -live demo
abstract
Live demo using Postman and show you can re-use code with a code library.
Dive into a new idea: "Postman Object Models".
A POM uses a code library with classes to persist data as Postman variables. The class objects can be used throughout your scripts with standard object references in your scripts. �eg. session.authToken
The POM classes are abstractions that hide the data persistence inside the class. You can create getters and setters for validation checks, and many other helper routines.
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
Postman object models -live demo
For example:
Use a POM to remember user session variables, such as a
Without a POM you would be storing the values in individual Postman variables, with unique, long/cryptic, names. This bloats the number of entries stored in the Postman variables.
Managing a long list of Postman variables is... problematic.
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
whoami
Vincent Dirks - full stack agile test analyst
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
whoareyou
test analysts starting their journey into automation
This presentation is aimed at people who are beginning their journey of learning to program automation scripts to help their testing.
I am not a developer, started programing inside tools like ReadyAPI and Postman 3 years ago.
I am aiming this talk to people who are similarly inexperienced with programming and realise we won’t let the developers have all the fun by themselves.
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
overview
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
the API under test
let’s explore the API created for this presentation
host: http://localhost:5000
routes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
Postman
as you might be using it now...
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
aside - javascript arrow functions
are ‘syntactically compact alternatives’
function nameOfFunction(inputParams){
do_some_stuff();
return x;
}
is the same as
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
aside - javascript array methods
with arrow functions are way cool
At some point we will receive a response containing an array
pm.expect(resp.info[2]).to.eql(someValue);)
pm.expect(� resp.info.find(item => item.includes(...))�).to.be.a(...);
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
I keep writing the same test script…
how to reuse code
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
codeLibrary
how to create one in Postman
pm.globals.set(`codeLibrary`,� `console.log("loading code library");`�);
eval(pm.globals.get(`codeLibrary`));
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
codeLibrary
"and" 'javascript' `strings`
these are all javascript strings
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
let’s code...
checkInfoResponse()
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
let’s test
/api/v1/info
eval(pm.globals.get(`codeLibrary`));
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
rinse and repeat
/api/v1/*/info
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
let’s reflect & any questions?
and how are we doing for time...
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
classes in the codeLibrary ?
I wonder if we could …?
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
using classes in the codeLibrary
account class
Notes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
using classes in the codeLibrary
get account response handler
Notes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
create the User class
design
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
User class
implementation
Notes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
can we persist js objects ?
let’s try save js objects to the globals
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
object persistence
design
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
object persistence
implementation (User class)
Notes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
let’s use it...
the User class
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
have some fun
select a random user
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
could we add the user’s accounts ?
after all they belong to the user
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
user accounts
implementation (User class)
Notes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
user accounts
User constructor changes
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
some more fun
get random account’s rate details and transactions
or
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
let’s reflect
Postman Object Model ...
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland
thank you & questions ?
resources
?
TESTINGMIND CONSULTING
- Test Automation and Digital QA Event | Auckland