Test Overview
This test checks if the API test tool can send a GET request to a sample API endpoint and verify the response status code is 200, confirming the API is reachable and working.
This test checks if the API test tool can send a GET request to a sample API endpoint and verify the response status code is 200, confirming the API is reachable and working.
import requests import unittest class TestAPI(unittest.TestCase): def test_get_status_code(self): response = requests.get('https://jsonplaceholder.typicode.com/posts/1') self.assertEqual(response.status_code, 200) if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test framework initializes the test case | - | PASS |
| 2 | Sends GET request to 'https://jsonplaceholder.typicode.com/posts/1' | Network call is made to the API endpoint | - | PASS |
| 3 | Receives response from API | Response object contains status code and data | - | PASS |
| 4 | Checks if response status code equals 200 | Response status code is 200 | self.assertEqual(response.status_code, 200) | PASS |
| 5 | Test ends with success | Test framework reports test passed | - | PASS |