Right now, your test considers any 2xx response a success. But what if the server returns a 200 OK with an empty body? Or returns an error message inside a 200 response? Assertions verify that the response contains what you expect -- not just that it returned something.
Right-click your HTTP Request → Add → Assertions → Response Assertion.
Field to Test: Response Code.
Pattern Matching Rules: Equals.
Patterns to Test: Add "200".
This asserts that the response code must be exactly 200.
| Assertion Type | What It Checks | Use Case |
|---|---|---|
| Response Assertion | Response code, body text, headers | Verify 200 OK, check body contains expected text |
| JSON Assertion | JSON path expressions | Verify API returns correct JSON structure |
| Duration Assertion | Response time threshold | Fail if response takes longer than 2 seconds |
| Size Assertion | Response size in bytes | Verify response is not empty or unexpectedly large |
| XPath Assertion | XML structure | Verify SOAP API responses |
The Duration Assertion fails a request if it takes longer than a specified time. This is your automated SLA check in JMeter.
Right-click your HTTP Request → Add → Assertions → Duration Assertion.
Duration in milliseconds: 2000 (2 seconds).
Any request taking longer than 2 seconds will be marked as FAILED in the results.
This appears as a red icon in View Results Tree with the message "Duration Assertion failure."
Add a Duration Assertion to every performance test. It turns your test from "did it respond?" into "did it respond fast enough?" Set it to your SLA threshold. A test with all 200 OK responses but half exceeding your SLA is a failing test.
Key Point: Assertions verify response content and timing -- not just HTTP status. Add Response Assertion for correctness and Duration Assertion for SLA compliance. A 200 OK that takes 10 seconds is a failure.
Key Point: Add Response Assertions for correctness and Duration Assertions for SLA checks -- a slow 200 OK is still a failure