0
0
Postmantesting~15 mins

Load testing basics (Postman) - Build an Automation Script

Choose your learning style9 modes available
Perform a basic load test on a REST API endpoint using Postman
Preconditions (3)
Step 1: Open Postman and create a new collection named 'Load Test Collection'
Step 2: Add a new GET request to the collection with the URL https://api.example.com/data
Step 3: Save the request
Step 4: Open the Postman Collection Runner
Step 5: Select the 'Load Test Collection'
Step 6: Set the number of iterations to 50
Step 7: Set the delay between requests to 0 ms
Step 8: Start the run
Step 9: Observe the results summary after completion
✅ Expected Result: All 50 requests complete successfully with status code 200, and the average response time is within acceptable limits (e.g., less than 500 ms)
Automation Requirements - Postman Collection Runner with built-in scripting
Assertions Needed:
Verify each response status code is 200
Verify response time is less than 500 ms for each request
Best Practices:
Use Postman test scripts to assert response status and time
Use Collection Runner to simulate multiple requests
Avoid hardcoding URLs inside test scripts; use variables
Keep delay between requests minimal for load testing
Analyze run summary for failures and response times
Automated Solution
Postman
pm.test('Status code is 200', () => {
    pm.response.to.have.status(200);
});

pm.test('Response time is less than 500ms', () => {
    pm.expect(pm.response.responseTime).to.be.below(500);
});

The test script uses Postman's pm.test function to create two checks for each request.

First, it verifies the HTTP status code is 200, meaning the request was successful.

Second, it checks that the response time is below 500 milliseconds to ensure the API performs well under load.

These scripts run automatically for each request during the Collection Runner execution, allowing us to validate all 50 iterations.

Common Mistakes - 3 Pitfalls
{'mistake': 'Not adding assertions in the test script', 'why_bad': "Without assertions, the test run won't verify if responses are correct or fast enough, missing failures.", 'correct_approach': 'Always add assertions for status code and response time in Postman test scripts.'}
Setting a high delay between requests during load testing
Hardcoding the API URL inside test scripts instead of using variables
Bonus Challenge

Now add data-driven testing by running the load test with 3 different API endpoints

Show Hint