0% found this document useful (0 votes)
31 views24 pages

Lesson 04 Environments

John is assigned to create an Environment in Postman and validate REST requests. An Environment allows grouping of variables and managing access to shared Postman data. Advanced validations check responses against schemas or specific fields. End-to-end test automation integrates the Postman test suite into the development lifecycle.

Uploaded by

ryadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views24 pages

Lesson 04 Environments

John is assigned to create an Environment in Postman and validate REST requests. An Environment allows grouping of variables and managing access to shared Postman data. Advanced validations check responses against schemas or specific fields. End-to-end test automation integrates the Postman test suite into the development lifecycle.

Uploaded by

ryadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Automation Testing

Environments
A Day in the Life of an Automation Testing Engineer

John is now assigned a task to create an Environment and validate the


REST requests in Postman.

After completing this session, John will be able to create a different


Environment to be used across requests and perform REST request
validations in Postman.
Learning Objectives

By the end of this lesson, you will be able to:

Identify an Environment in Postman

State the usage of an Environment

Explain the advance validation on response in REST Assured

List the steps to perform end-to-end case automation


What Is an Environment?
What Is an Environment?

An Environment is a set of variables users can use in their Postman requests.


Users can use an Environment to group related sets of values.

They can also manage access to the shared Postman data.


Features of an Environment

Environments allow users to control the visibility of sensitive data, such as API secrets,
passwords, tokens, and keys and work on shared resources.

Any global variables they add or modify in a shared workspace will be accessible to everyone
else in the workspace.

Variables can be defined as secret types to hide the initial and current values for every
workspace member and avoid unintended disclosure of sensitive information.

Users can move Environments into shared workspaces to work with the team.
Usage of Environments
Usage of an Environment

Users can use an Environment to collaborate on shared resources and configure the visibility
of sensitive data, including API secrets, passwords, tokens, and keys.

Source: learning.postman.com
Managing Environment Variables

Creating an Environment is simple. Here are the steps to create an Environment:

• Click on the New button


• Select the Environment option
• Enter user ID in the VARIABLE column's first field
• Set INITIAL VALUE to 1
• Click on Save to save the Environment
• Exit the dialog box
Managing Environment Variables

• Click the drop-down menu on the upper right corner


of the screen
• Select Environment_01 from the drop-down list
• Send a Get request

Users can send Get requests as the Environment is


already active.
End-to-End Case Automation
End-to-End Case Automation

Users need to integrate automated testing in the CI/CD pipeline to ensure the changes in the
code will not break the API during production.
End-to-End Case Automation

1 Understand the API

2 Build the test suite

3 Work and verify with team

4 Parameterize requests

5 Run the tests and debug

6 Integrate with DevOps lifecycle


Automation Suite Creation with Postman

Here are some terms and their meanings used in Postman that users need to know before
constructing an automation suite in the tool:

Collection Global/Environmental Variables

It is a bunch of saved requests that users A set of key-value pairs is called an


can organize into folders. It aids in the Environment. It allows users to customize
creation of comprehensible request requests with variables, enabling them to
hierarchies. move between different setups without
changing the requests quickly.
Automation Suite Creation with Postman

Authentication Options Pre-Request

Authorization is used by APIs to verify if Pre-request scripts are pieces of code


the client requests have secure access to executed before a Collection request is
data. Postman supports a variety of issued. These are commonly used to
authorization techniques as well. generate values and inject them into
requests through Environment variables.
Automation Suite Creation with Postman

Tests In-built JS Snippets

Tests are JavaScript-based scripts that are Postman allows users to develop a
run after a response is received. JavaScript code that asserts responses
Tests can be executed as part of a single and checks them automatically.
request or a set of requests. Assertions can be written using the
Snippets feature of the Tests tab.
Advance Validation on Response in Rest Assured
Advance Validation on Response in Rest Assured

There are advanced assertions used in Postman to validate a response in different complex
ways. Advanced validations are of two types:

Response body validation against Schema

var jsonResponse = pm.response.json();


pm.test('Schema is valid', function()
{pm.expect(tv4.validate(jsonResponse, schema)) .to.be.
true;});
Advance Validation on Response in Rest Assured

There are advanced assertions used in Postman to validate a response in different complex
ways. Advanced validations are of two types:

Assertion of a value in the particular field on JSON

pm.test("value of per page field is 6", function () {


var jsonData = pm.response.json();
pm.expect(jsonData.per_page).to.eql(6);});
How to Validate a Get Response?
Validation in Postman

Here are some features of validating documents, tests, monitors, and more in Postman:

Users can check elements, It maintains the clarity of The API elements can then
such as documents, tests, their API and guarantees be fixed and revalidated.
fake servers, monitors, that the items are
and so on, against their consistent with the
API schema in Postman. schema. Postman
displays a list of issues
discovered along with
the remedies, if there is
a validation error on the
schema, or if elements
do not fit.
Validation in Postman

Validating schemas Validating elements Validating requests

Postman highlights the Users may assess whether When a request is sent,
validation problems that the elements of their API Postman verifies it. If there
arise as users change their schemas need to be changed are problems with the
API schema on the to stay in sync. The request, Postman displays a
Definition tab on the API assessment is done by warning message with the
version page. comparing the elements to request's name, and the
These errors include missing the documentation, mock number of problems
mandatory fields, improper servers, tests, and associated adjacent to it.
field names, inappropriate monitors.
data types, incorrect nesting,
and other API schema
validation problems.
Key Takeaways

Users can use an Environment to collaborate on shared


resources and configure the visibility of sensitive data,
including API secrets, passwords, tokens, and keys.

An Environment can be used to group related sets of values


and manage access to shared Postman data.

There are advanced assertions used in Postman to validate a


response in different complex ways.

End-to-end test cases can be automated using the


Postman API suite.

You might also like