๐๏ธ Foundations ยท Days 1โ6
Day 4: Assertions = Truth
Objective
Add response, status, and body assertions. Intentionally break one to watch it fail.
Scenario
Assert HTTP 200. Assert a specific string exists in the response body. Then change the expected string to something wrong and re-run. The test should fail loudly.
Metrics to Watch
When It Clicks
A 'passing' load test with no assertions can be silently serving error pages.
Solution
In JMeter: add a Response Assertion to your sampler. Check 'Response Code' equals 200, and 'Response Body' contains a known string (e.g. a JSON key or page title). To see it fail: change the expected string to 'INTENTIONAL_FAIL' and re-run. The error % will jump to 100% and View Results Tree will show red. In k6: use `check(res, { 'status 200': (r) => r.status === 200, 'body has key': (r) => r.body.includes('expected') })` and add a threshold to fail the test.
Reflection
Have you ever trusted green results that were actually hiding failures?
Deliverable
A script with meaningful assertions.
โ ๏ธ Never run load tests against infrastructure you do not own or have explicit written permission to test. Always use a dedicated test environment. Unauthorized load injection can cause outages, trigger legal liability, and violate terms of service.