- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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
How to set Test and Collection Runner in Postman?
We can add test verifications to the Response obtained from a request with the help of scripts. These scripts are incorporated in the Tests tab. The tests only get executed provided the request is successful.
tests["Status Code should be 200"] = responseCode.code === 200 tests["Response time lesser than 10ms"] = responseTime<10
The tests is a variable of type array which can have values with data types- integer, string, Boolean and so on. The Status Code should be 200 and Response time lesser than 10ms are test names. We should give a meaningful name to the test. The responseCode.code is the code obtained in the Response and the responseTime is the time taken to get the Response.
Choose an HTTP method and enter an URL, then click on Send.
Response code obtained is 200 OK and response time is 129ms (the second test verifies if the Response time is lesser than 10ms). The above test shows the Response with Test Results(1/2) meaning one out of the two tests got passed. The first test passed and the second one failed with the Assertion error.
Let us take a Collection having multiple requests and execute them with the help of the Collection Runner.
Step 1 − Click on the Runner menu in the Postman application.
Step 2 − Collection Runner window opens up.
Step 3 − Choose the Collection name from the Choose a collection or folder section.
Step 4 − Choose an Environment if the requests in the Collection need to be executed in a particular Environment. Enter the number of iterations for the request and delay time for the requests.
Step 5 − If the data for the requests are from a file, we can select the file type from the Data field. Finally, click on Run Collection1.
Step 6 − The Run Results section of the Collection Runner window opens up. The Environment, Collection name and passed/failed count are displayed at the top. For each request, the Response status code, time taken, payload size, and test verifications are populated.
We will find in the below image that the test – Status Code is 200 has been executed for all the requests in both the iterations. In case there is no test implemented for a particular request, then it shall display the message as - This request does not have any tests.
- Related Articles
- 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 to Import Collection in Postman?
- How test runner prioritize test classes for execution in Selenium?
- How to create and save a collection in Postman?
- How to create a test runner file for Cucumber in Java?
- How to run tests using a test runner file for Cucumber?
- How to set a global variable in Postman?
- Run Postman Collection on Jenkins
- How to Run Postman Collection on Jenkins using Newman Commands?
- How to set Tests using Functional Method in Postman?