Test Overview
This test checks if a web API correctly handles a GET request and returns the expected status code 200, indicating success.
This test checks if a web API correctly handles a GET request and returns the expected status code 200, indicating success.
import requests import unittest class TestAPIRequestMethods(unittest.TestCase): def test_get_request_status_code(self): url = "https://jsonplaceholder.typicode.com/posts/1" response = requests.get(url) self.assertEqual(response.status_code, 200) if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test framework initialized, ready to run test_get_request_status_code | - | PASS |
| 2 | Sends GET request to https://jsonplaceholder.typicode.com/posts/1 | HTTP request sent to the API endpoint | - | PASS |
| 3 | Receives HTTP response from the server | Response object contains status code and data | - | PASS |
| 4 | Checks if response status code equals 200 | Response status code is 200 OK | Assert response.status_code == 200 | PASS |
| 5 | Test completes successfully | Test framework reports test passed | - | PASS |