- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Test and Collection Runner in Postman
We can have checkpoints to verify the Response from a request. This is done by adding scripts in the Tests tab. These scripts get executed if the request has executed successfully.
The scripts added under the Tests tab are developed in JavaScript. After a request has been sent and a Response is received, the outcome of these test scripts are reflected in the Test Results tab in the Response. The passed tests are marked ingreen and the failed tests are in red.
Input the below tests in the Tests tab −
tests["Status Code should be 200"] = responseCode.code === 200 tests["Response time lesser than 10ms"] = responseTime<10
The tests is a variable of array type which can store values of data types- integer,string, Boolean and so on. The Status Code should be 200 and Response time lesser than 10ms are test names. The responseCode.code is the code yielded in the Response and the responseTime is the time consumed to obtain the Response.
Select a method, type an URL and click on the Send button.
Response code obtained is 200 OK and response time is 129ms (the second test checks if the Response time is lesser than 10ms). The Test Results(1/2) reflects the fact that one test out of the two has passed.
Let us take a Collection with more than one request and execute them via the Collection Runner.
Step 1 − Click on the Runner menu.
Step 2 − The Collection Runner pop-up comes up.
Step 3 − Select the name of the Collection from the Choose a collection or folder segment.
Step 4 − Choose an Environment and input the number of iterations and request delay time.
Step 5 − In case the data for the requests is from a file, we have to choose the file type from the Data field and then click on Run Collection1.
Step 6 − Run Results section of the Collection Runner window is displayed. The Environment, Collection name and passed/failed numbers are available on the top of the window. For individual requests, the Response status code, time taken, size, and tests (Status Code is 200) information are visible.
- Related Articles
- How to set Test and Collection Runner in Postman?
- Collection Runner in Postman?
- How to run Collection Runner in Postman?
- What is Execution order of Collection Runner in Postman?
- Cypress Test Runner (Test Automation)
- How test runner prioritize test classes for execution in Selenium?
- How to Import Collection in Postman?
- How to create and save a collection in Postman?
- Run Postman Collection on Jenkins
- How to create a test runner file for Cucumber in Java?
- Setting test iterations using Newman (Postman)
- How to run tests using a test runner file for Cucumber?
- Running the collection using Newman through share link in Postman
- Running the collection using Newman through JSON file in Postman
- How to set a Test in Postman with JavaScript Method?
