What is response time benchmarking in API testing?
Response time benchmarking is measuring how long an API takes to respond to a request. It helps check if the API is fast enough for users.
Click to reveal answer
beginner
Why is it important to set a response time threshold in Postman tests?
Setting a threshold helps decide if the API is performing well or slow. If response time is above the threshold, the test fails, showing a performance problem.
Click to reveal answer
intermediate
How can you check response time in Postman test scripts?
Use the built-in variable pm.response.responseTime to get the response time in milliseconds. Then write assertions to compare it with your expected limit.
Click to reveal answer
intermediate
Example of a Postman test to fail if response time is over 500ms?
pm.test('Response time is under 500ms', () => {
pm.expect(pm.response.responseTime).to.be.below(500);
});
Click to reveal answer
intermediate
What factors can affect API response time during benchmarking?
Network speed, server load, request size, and backend processing all affect response time. Testing should consider these to get realistic results.
Click to reveal answer
In Postman, which variable holds the API response time in milliseconds?
Apm.response.responseTime
Bpm.response.time
Cpm.response.duration
Dpm.response.elapsed
✗ Incorrect
pm.response.responseTime is the correct variable to get response time in Postman test scripts.
Why should you benchmark response time in API testing?
ATo check if API returns correct data
BTo verify API security
CTo test API user interface
DTo measure how fast the API responds
✗ Incorrect
Benchmarking response time measures how fast the API responds, which is key for performance.
What happens if a Postman test asserts response time below 300ms but actual time is 400ms?
ATest is skipped
BTest passes
CTest fails
DTest retries automatically
✗ Incorrect
If actual response time is above the threshold, the assertion fails and so does the test.
Which of these is NOT a factor affecting API response time?
ANetwork speed
BUser interface color
CServer load
DRequest size
✗ Incorrect
User interface color does not affect API response time.
How can you automate response time checks in Postman?
ABy writing test scripts using pm.response.responseTime
BBy manually measuring time with a stopwatch
CBy checking response body content
DBy using Postman’s visualizer only
✗ Incorrect
Writing test scripts with pm.response.responseTime automates response time checks.
Explain how to write a Postman test script to benchmark response time and fail if it exceeds a limit.
Think about how to get response time and check it with pm.expect
You got /3 concepts.
List common factors that can influence API response time during benchmarking.
Consider what happens between sending a request and getting a response
You got /4 concepts.
Practice
(1/5)
1. What does pm.response.responseTime measure in Postman?
easy
A. The time taken by the server to respond to a request
B. The size of the response body
C. The number of requests sent
D. The status code of the response
Solution
Step 1: Understand the purpose of pm.response.responseTime
This property records how long the server takes to send back a response after a request is made.
Step 2: Differentiate from other response properties
It does not measure response size, count requests, or check status codes; it only measures response speed.
Final Answer:
The time taken by the server to respond to a request -> Option A
Quick Check:
Response time = server speed [OK]
Hint: Response time means how fast server replies [OK]
Common Mistakes:
Confusing response time with response size
Thinking it counts requests instead of timing
Mixing it up with status code checks
2. Which of the following is the correct way to assert that response time is less than 500 milliseconds in Postman test script?
easy
A. pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.equal(500));
B. pm.test('Response time is less than 500ms', () => pm.response.responseTime < 500);
C. pm.test('Response time is less than 500ms', () => pm.response.responseTime > 500);
D. pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.be.below(500));
Solution
Step 1: Identify correct assertion syntax in Postman
Postman uses Chai assertion library syntax: pm.expect(value).to.be.below(limit) to check if value is less than limit.
Step 2: Check each option's logic and syntax
pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.be.below(500)); correctly uses pm.expect(pm.response.responseTime).to.be.below(500). pm.test('Response time is less than 500ms', () => pm.response.responseTime < 500); lacks assertion method. The version checking greater than 500 reverses the logic, and the version checking equality to 500 uses the wrong matcher.
Final Answer:
pm.test('Response time is less than 500ms', () => pm.expect(pm.response.responseTime).to.be.below(500)); -> Option D
Quick Check:
Use pm.expect(...).to.be.below(...) for less than checks [OK]
Hint: Use pm.expect(...).to.be.below(value) for less than checks [OK]
If the actual response time is 350 ms, what will be the test result?
medium
A. Test fails because 350 is not below 300
B. Test passes because 350 is below 300
C. Test passes because response time is ignored
D. Test throws a syntax error
Solution
Step 1: Understand the assertion condition
The test expects response time to be less than 300 ms using to.be.below(300).
Step 2: Compare actual response time with expected limit
The actual response time is 350 ms, which is greater than 300 ms, so the assertion fails.
Final Answer:
Test fails because 350 is not below 300 -> Option A
Quick Check:
350 > 300 means assertion fails [OK]
Hint: If actual > limit, test fails for 'to.be.below' [OK]
Common Mistakes:
Thinking 350 is less than 300
Assuming test passes without checking values
Confusing syntax error with assertion failure
4. You wrote this Postman test to check response time:
pm.test('Response time under 200ms', () => {
pm.expect(pm.response.responseTime).below(200);
});
But the test always passes even when response time is 500 ms. What is the error?
medium
A. Response time property is misspelled
B. Using pm.expect incorrectly without parentheses
C. Missing to.be before below(200)
D. Test name is incorrect
Solution
Step 1: Check assertion syntax correctness
The correct Chai syntax requires chaining to.be.below(200). The code uses pm.expect(...).below(200) missing to.be.
Step 2: Understand effect of missing chain
Without to.be, the assertion does not execute properly and silently passes, ignoring the actual response time.
Final Answer:
Missing to.be before below(200) -> Option C
Quick Check:
Use full chain pm.expect(...).to.be.below(...) [OK]
Hint: Always use pm.expect(...).to.be.below(...) chain [OK]
Common Mistakes:
Omitting 'to.be' in assertion chain
Misspelling responseTime property
Ignoring test failure due to syntax
5. You want to benchmark response times for multiple API endpoints in Postman and fail the test if any response time exceeds 400 ms. Which approach is best?
hard
A. Write a test script in each request using pm.expect(pm.response.responseTime).to.be.below(400)
B. Use a collection-level test script that checks pm.response.responseTime after each request
C. Manually check response times in Postman console after running all requests
D. Set a global variable with response time and compare after all requests finish
Solution
Step 1: Understand scope of test scripts in Postman
Collection-level scripts run after every request in the collection, allowing centralized checks for all endpoints.
Step 2: Compare options for efficiency and automation
Use a collection-level test script that checks pm.response.responseTime after each request automates response time checks for all requests without repeating code. Writing a test script in each request using pm.expect(pm.response.responseTime).to.be.below(400) duplicates code, manually checking response times in Postman console after running all requests is error-prone, and setting a global variable with response time and comparing after all requests finish complicates logic unnecessarily.
Final Answer:
Use a collection-level test script that checks pm.response.responseTime after each request -> Option B
Quick Check:
Collection-level scripts automate checks for all requests [OK]
Hint: Use collection-level tests to check all response times automatically [OK]
Common Mistakes:
Repeating same test in every request script
Relying on manual checking instead of automation
Overcomplicating with global variables
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.