Test Overview
This test simulates a simple performance test scenario using a tool like Apache JMeter. It verifies that the tool can send a request to a web server and measure the response time correctly.
This test simulates a simple performance test scenario using a tool like Apache JMeter. It verifies that the tool can send a request to a web server and measure the response time correctly.
import unittest import time import requests class PerformanceTest(unittest.TestCase): def test_response_time_under_limit(self): url = "https://example.com" max_response_time = 0.5 # seconds start_time = time.time() response = requests.get(url) end_time = time.time() response_time = end_time - start_time self.assertEqual(response.status_code, 200) self.assertLessEqual(response_time, max_response_time, f"Response time {response_time} exceeded limit") if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initializes the PerformanceTest class | - | PASS |
| 2 | Sends HTTP GET request to https://example.com | Network connection established, request sent | - | PASS |
| 3 | Receives HTTP response | Response received with status code 200 and response body | Check if response.status_code == 200 | PASS |
| 4 | Measures response time | Response time calculated as end_time - start_time | Check if response_time <= 0.5 seconds | PASS |
| 5 | Test ends with all assertions passed | Test report shows success | - | PASS |