0
0
Testing Fundamentalstesting~10 mins

API test tools overview in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
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.

Test Code - unittest
Testing Fundamentals
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()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsTest framework initializes the test case-PASS
2Sends GET request to 'https://jsonplaceholder.typicode.com/posts/1'Network call is made to the API endpoint-PASS
3Receives response from APIResponse object contains status code and data-PASS
4Checks if response status code equals 200Response status code is 200self.assertEqual(response.status_code, 200)PASS
5Test ends with successTest framework reports test passed-PASS
Failure Scenario
Failing Condition: API endpoint is unreachable or returns a status code other than 200
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the API?
AThe API returns JSON data
BThe API returns status code 200
CThe API response time is under 1 second
DThe API requires authentication
Key Result
Always verify the API response status code to confirm the endpoint is reachable and functioning before validating response data.