API Test Cases & API Testing Test Cases: API testing is an important step in the development of any application. The need for this is that applications nowadays are connected through APIs, which serve as the glue between applications.
Testing APIs is critical to maintaining and improving your product’s quality. It allows you to validate that all the endpoints are functional and following the documentation. It also allows you to prevent errors before they even occur.
Post On: | API Testing Test Cases |
Post Type: | Test Case Template |
Published On: | www.softwaretestingo.com |
Applicable For: | Freshers & Experience |
Get Updates: | Software Testingo Telegram Group |
Testing APIs is becoming a very common requirement. However, finding real and relevant use cases to test them against is often too hard. This article has collected some API testing tips to help you deliver better tests faster.
Testing APIs is no longer a low-risk endeavor. It is becoming essential for any company’s IT department to ensure the security of its applications and web services. With the increasing number of exposed APIs, testing becomes even more important. This article will provide tips and examples for testing your APIs effectively and efficiently.
You can also face questions like this for the same test cases: API test cases, API test cases in Excel, sample API test cases in Excel sheet, API testing test cases, test cases for API testing, sample manual test cases for API testing, sample test cases for API testing, sample API test cases, API test case template.
Test cases for API Testing
- Validate the keys with the Min. and Max range of APIs (e.g., maximum and minimum length)
- Keys verification. If we have JSON or XML APIs, we should verify that all the keys are coming.
- Have a test case to do XML and JSON Schema validation.
- Verify the Parse the Response data.
- Verify the JSON Schema validation, the Field Type, and the Mandatory Fields.
- Valid Response headers and negative cases response
- Verify how the API error codes are handled.
- Verify the response HTTP status code.
- Valid Response payload
- Chaining Request verification.
- Verification of APIs with Data parameters.
- End to End CRUD flows
- Database Integrity Test Cases
- File Upload Test cases
API Testing Test Cases
- Verify that the API response status code is 200 OK.
- Verify that the API response is in the expected format (e.g., JSON, XML).
- Verify that the API response contains all the expected fields.
- Verify that the API response contains the correct data for each field.
- Verify that the API response time is within acceptable limits.
- Verify that the API request parameters are correctly passed to the API.
- Verify that the API request method is correct (e.g., GET, POST, PUT, DELETE).
- Verify that the API endpoint URL is correct.
- Verify that the API response headers are correct.
- Verify that the API response payload size is within acceptable limits.
- Verify that the API returns an error message if the request is malformed.
- Verify that the API returns an error message if the authentication fails.
- Verify that the API returns an error message if the request payload is missing.
- Verify that the API returns an error message if the requested resource does not exist.
- Verify that the API returns an error message if the requested resource is not authorized.
- Verify that the API returns an error message if the request payload exceeds the allowed limit.
- Verify that the API returns an error message if the request payload contains invalid data.
- Verify that the API returns an error message if the request method is not allowed for the resource.
- Verify that the API returns a success message if the resource is created successfully.
- Verify that the API returns a success message if the resource is updated successfully.
- Verify that the API returns a success message if the resource is deleted successfully.
- Verify that the API returns a success message if the resource is retrieved successfully.
- Verify that the API returns the correct resource based on the provided resource identifier.
- Verify the API returns the correct resource based on the provided search parameters.
- Verify that the API response contains the correct pagination information.
- Verify that the API response contains the correct sorting order based on the provided sort parameter.
- Verify that the API response contains the correct filtering information based on the provided filter parameters.
- Verify that the API returns the correct results when searching for a partial string.
- Verify that the API returns the correct results when searching for a case-insensitive string.
- Verify that the API returns the correct results when searching for a special-character string.
- Verify that the API returns the correct results when searching for multiple-word strings.
- Verify that the API returns the correct results when searching for a string combining letters and numbers.
- Verify that the API returns the correct results when searching for a string with spaces.
- Verify that the API returns the correct results when searching for a string with non-ASCII characters.
- Verify that the API returns the correct results when searching for a string with mixed character types (e.g., letters, numbers, symbols).
- Verify that the API returns the correct results when searching for a string with HTML tags.
- Verify that the API returns the correct results when searching for a string with escape characters.
- Verify that the API response contains the correct resource representation based on the provided content type.
- Verify that the API response is compressed when the client sends a request with the “Accept-Encoding” header set to “gzip”.
- Verify that the API response is not compressed when the client does not send the “Accept-Encoding” header.
- Verify that the API response is not compressed when the client sends a request with the “Accept-Encoding” header set to a value other than “gzip”.
- Verify that the API response contains the correct resource representation based on the specified language (e.g., English, Spanish, French).
- Verify that the API response contains the correct resource representation based on the specified locale (e.g., en-US, fr-FR).
- Verify that the API response contains the correct resource representation based on the specified time zone.
- Verify that the API response contains the correct resource representation when the resource contains nested objects or arrays.
- Verify that the API returns a response within a specified timeout period.
- Verify that the API handles concurrent requests correctly.
- Verify that the API handles partial updates correctly (e.g., PATCH requests).
- Verify that the API returns a response with a custom HTTP header when a specific request header is sent.
- Verify that the API correctly handles file uploads and downloads.
- Verify that the API response contains the correct resource representation based on the specified currency.
- Verify that the API correctly handles rate limiting and returns the correct HTTP status code.
- Verify that the API handles retries and returns the correct HTTP status code.
- Verify that the API correctly handles redirects and returns the correct HTTP status code.
- Verify that the API correctly handles cookies and returns the correct HTTP status code.
- Verify that the API correctly handles caching and returns the correct HTTP status code.
- Verify that the API correctly handles CSRF tokens and returns the correct HTTP status code.
- Verify that the API handles cross-site scripting (XSS) attacks and returns the correct HTTP status code.
- Verify that the API handles SQL injection attacks correctly and returns the correct HTTP status code.
- Verify that the API handles cross-site request forgery (CSRF) attacks and returns the correct HTTP status code.
- Verify that the API correctly handles input validation and returns the correct HTTP status code.
- Verify that the API correctly handles output encoding and returns the correct HTTP status code.
- Verify that the API handles SSL/TLS certificates correctly and returns the correct HTTP status code.
- Verify that the API correctly handles content negotiation and returns the correct HTTP status code.
- Verify that the API handles authentication and authorization correctly and returns the correct HTTP status code.
- Verify that the API handles request rate limiting and returns the correct HTTP status code.
- Verify that the API handles retry attempts and returns the correct HTTP status code.
- Verify that the API correctly handles timeouts and returns the correct HTTP status code.
- Verify that the API correctly handles network failures and returns the correct HTTP status code.
- Verify that the API correctly handles race conditions and returns the correct HTTP status code.
- Verify that the API correctly handles caching and returns the correct HTTP status code.
- Verify that the API correctly handles versioning and returns the correct HTTP status code.
- Verify that the API correctly handles version negotiation and returns the correct HTTP status code.
- Verify that the API correctly handles content negotiation and returns the correct HTTP status code.
- Verify that the API handles partial updates and returns the correct HTTP status code.
- Verify that the API correctly handles error conditions and returns the correct HTTP status code and error message.
- Verify that the API correctly handles various requests, such as GET, POST, PUT, DELETE, OPTIONS, HEAD, and PATCH.
- Verify that the API correctly handles various types of data, such as strings, numbers, dates, and binary data.
- Verify that the API correctly handles various types of authentication, such as basic authentication, token authentication, and OAuth.
- Verify that the API correctly handles various types of authorization, such as role-based
- Verify that the API returns the correct HTTP status code for requests that are not supported (e.g., HTTP 405 Method Not Allowed).
- Verify that the API returns the correct HTTP status code for invalid requests (e.g., HTTP 400 Bad Request).
- Verify that the API returns the correct HTTP status code for unauthorized requests (e.g., HTTP 401 Unauthorized).
- Verify that the API returns the correct HTTP status code for forbidden requests (e.g., HTTP 403 Forbidden).
- Verify that the API returns the correct HTTP status code for resources not found (e.g., HTTP 404 Not Found).
- Verify that the API correctly handles pagination and returns the correct resources for each page.
- Verify that the API correctly handles the sorting and filtering of resources.
- Verify that the API correctly handles searching for resources based on specific criteria.
- Verify that the API correctly handles batch requests and returns the correct resources for each batch.
- Verify that the API correctly handles webhooks and delivers the correct events to subscribed clients.
- Verify that the API correctly handles server-side validation and returns the correct HTTP status code and error message.
- Verify that the API correctly handles client-side validation and returns the correct HTTP status code and error message.
- Verify that the API correctly handles field-level validation and returns the correct HTTP status code and error message.
- Verify that the API correctly handles database transactions and returns the correct HTTP status code and error message.
- Verify that the API correctly handles database backups and restores and returns the correct HTTP status code and error message.
- Verify that the API correctly handles encryption and decryption of data.
- Verify that the API correctly handles the compression and decompression of data.
- Verify that the API handles rate limiting based on a user account or IP address.
- Verify that the API correctly handles authentication based on the user account or API key.
- Verify that the API correctly handles authorization based on user roles or permissions.
- Verify that the API correctly handles cross-origin resource sharing (CORS) and returns the correct HTTP status code and error message.
- Verify that the API correctly handles input sanitization and returns the correct HTTP status code and error message.
- Verify that the API correctly handles output sanitization and returns the correct HTTP status code and error message.
- Verify that the API handles SQL injection prevention correctly and returns the correct HTTP status code and error message.
- Verify that the API correctly handles cross-site scripting (XSS) prevention and returns the correct HTTP status code and error message.
- Verify that the API correctly handles cross-site request forgery (CSRF) prevention and returns the correct HTTP status code and error message.
- Verify that the API correctly handles broken links and returns the correct HTTP status code and error message.
- Verify that the API handles CORS preflight requests correctly and returns the correct HTTP status code and error message.
- Verify that the API correctly handles multi-language support and returns the correct resources for each language.
- Verify that the API correctly handles multi-currency support and returns the correct resources for each currency.
- Verify that the API correctly handles multi-timezone support and returns the correct resources for each timezone.
- Verify that the API correctly handles multi-locale support and returns the correct resources for each locale.
- Verify that the API correctly handles multi-region support and returns the correct resources for each region.
- Verify that the API correctly handles multi-tenant support and returns the correct resources for each tenant.
- Verify that the API correctly handles multi-environment support and returns the correct resources for each environment.
- Verify that the API correctly handles multi-platform support
- Verify that the API returns the correct response time for requests (e.g. GET, POST, PUT, DELETE).
- Verify that the API correctly handles large payloads and returns the correct HTTP status code and error message.
- Verify that the API correctly handles small payloads and returns the correct HTTP status code and error message.
- Verify that the API correctly handles concurrent requests and returns the correct resources for each request.
- Verify that the API correctly handles slow requests and returns the correct HTTP status code and error message.
- Verify that the API correctly handles high traffic and returns the correct HTTP status code and error message.
- Verify that the API correctly handles low traffic and returns the correct HTTP status code and error message.
- Verify that the API correctly handles error recovery and returns the correct HTTP status code and error message.
- Verify that the API correctly handles failover and returns the correct HTTP status code and error message.
- Verify that the API correctly handles load balancing and returns the correct HTTP status code and error message.
- Verify that the API correctly handles server clustering and returns the correct HTTP status code and error message.
- Verify that the API correctly handles versioning and returns the correct resources for each version.
- Verify that the API correctly handles API documentation and returns the correct resources for each API endpoint.
- Verify that the API correctly handles API change logs and returns the correct resources for each API change.
- Verify that the API correctly handles API testing and returns the correct resources for each API test.
- Verify that the API correctly handles API monitoring and returns the correct resources for each API metric.
- Verify that the API correctly handles API security and returns the correct resources for each API vulnerability.
- Verify that the API correctly handles API performance and returns the correct resources for each API performance metric.
- Verify that the API correctly handles API scalability and returns the correct resources for each API scalability metric.
- Verify that the API correctly handles API availability and returns the correct resources for each API availability metric.
- Verify that the API correctly handles API reliability and returns the correct resources for each API reliability metric.
- Verify that the API correctly handles API maintainability and returns the correct resources for each API maintainability metric.
- Verify that the API correctly handles API usability and returns the correct resources for each API usability metric.
- Verify that the API correctly handles API accessibility and returns the correct resources for each API accessibility metric.
- Verify that the API correctly handles API localization and returns the correct resources for each API localization metric.
- Verify that the API correctly handles API internationalization and returns the correct resources for each API internationalization metric.
- Verify that the API correctly handles API compliance and returns the correct resources for each API compliance metric.
- Verify that the API correctly handles API analytics and returns the correct resources for each API analytic metric.
- Verify that the API correctly handles API audit logs and returns the correct resources for each API audit log.
- Verify that the API correctly handles API error logs and returns the correct resources for each API error log.
- Verify that the API correctly handles API debug logs and returns the correct resources for each API debug log.
- Verify that the API correctly handles API performance logs and returns the correct resources for each API performance log.
- Verify that the API correctly handles API security logs and returns the correct resources for each API security log.
- Verify that the API correctly handles API usage logs and returns the correct resources for each API usage log.
- Verify that the API correctly handles API event logs and returns the correct resources for each API event log.
- Verify that the API correctly handles the API version.
Sample Excel Sheet Format
Test Case ID | Test Case Description | Test Steps | Expected Result | Actual Result | Status |
---|---|---|---|---|---|
TC01 | Verify API Response Status Code | Send API request to [Endpoint]. | HTTP status code should be 200 OK. | ||
TC02 | Verify API Response Format (JSON, XML) | Send API request to [Endpoint]. | The response format should be [JSON/XML]. | ||
TC03 | Verify API Response Contains Expected Fields | Send API request to [Endpoint]. | The response should contain expected fields. | ||
TC04 | Verify API Response Data for Each Field | Send API request to [Endpoint]. | The response data should be correct. | ||
TC05 | Verify API Response Time Within Acceptable Limits | Send API request to [Endpoint]. | The response time should be within limits. | ||
TC06 | Verify API Request Parameters Correctly Passed | Send API request to [Endpoint] with correct parameters. | Parameters should be correctly passed. | ||
TC07 | Verify the API Request Method Correct (GET, POST, etc.) | Send API request with the correct method (GET/POST/PUT/DELETE). | The method used should be correct. | ||
TC08 | Verify API Endpoint URL | Verify the API endpoint URL. | The endpoint URL should be correct. | ||
TC09 | Verify API Response Headers | Send API request to [Endpoint]. | Response headers should be correct. | ||
TC10 | Verify API Response Payload Size | Send API request to [Endpoint]. | Response payload size should be within limits. | ||
TC11 | Verify API Handles Malformed Requests | Send a malformed API request. | API should return an error message. | ||
TC12 | Verify API Handles Authentication Failure | Send API requests with incorrect authentication. | API should return an authentication error. | ||
TC13 | Verify API Handles Missing Request Payload | Send API request with missing payload. | API should return an error message. | ||
TC14 | Verify API Handles Non-Existent Resource | Send API requests for a non-existent resource. | API should return a resource not found error. | ||
TC15 | Verify API Handles Unauthorized Access | Send API requests without proper authorization. | API should return an authorization error. | ||
TC16 | Verify API Handles Request Payload Size Limit | Send API requests with payload exceeding the limit. | API should return an error message. | ||
TC17 | Verify API Handles Invalid Request Data | Send API requests with invalid data in the payload. | API should return an error message. | ||
TC18 | Verify API Handles Invalid Request Method | Send API request with an invalid method. | API should return a method that does not allow error. | ||
TC19 | Verify API Returns Success for Resource Creation | Send API request to create a resource. | API should return a success message. | ||
TC20 | Verify API Returns Success for Resource Update | Send API request to update a resource. | API should return a success message. | ||
TC21 | Verify API Returns Success for Resource Deletion | Send API request to delete a resource. | API should return a success message. | ||
TC22 | Verify API Returns Success for Resource Retrieval | Send API request to retrieve a resource. | API should return a success message. | ||
TC23 | Verify API Returns Correct Resource by Identifier | Send API requests with a specific identifier. | API should return the correct resource. | ||
TC24 | Verify API Returns Correct Resource by Parameters | Send API requests with specific search parameters. | API should return the correct resource. | ||
TC25 | Verify API Response Contains Pagination Info | Send API request to [Endpoint]. | The response should contain pagination info. | ||
TC26 | Verify API Response Sorting Based on Parameters | Send API request with sorting parameters. | The response should be sorted correctly. | ||
TC27 | Verify API Response Contains Filtering Info | Send API requests with filtering parameters. | The response should be filtered correctly. | ||
TC28 | Verify API Returns Correct Results for Partial String | Send API request for a partial string search. | API should return the correct results. | ||
TC29 | Verify API Returns Correct Results for Case-Insensitive String | Send API request for a case-insensitive string search. | API should return the correct results. | ||
TC30 | Verify API Returns Correct Results for String with Special Characters | Send an API request for a string with a special characters search. | API should return the correct results. | ||
TC31 | Verify API Returns Correct Results for Multi-Word String | Send API request for a multi-word string search. | API should return the correct results. | ||
TC32 | Verify API Returns Correct Results for Alphanumeric String | Send API request for an alphanumeric string search. | API should return the correct results. | ||
TC33 | Verify API Returns Correct Results for String with Spaces | Send API request for a string with spaces search. | API should return the correct results. | ||
TC34 | Verify API Returns Correct Results for String with Non-ASCII Characters | Send an API request for a string with a non-ASCII characters search. | API should return the correct results. | ||
TC35 | Verify API Returns Correct Results for String with Mixed Character Types | Send API request for a string with mixed character types search. | API should return the correct results. | ||
TC36 | Verify API Returns Correct Results for String with HTML Tags | Send API request for a string with HTML tags search. | API should return the correct results. | ||
TC37 | Verify API Returns Correct Results for String with Escape Characters | Send API request for a string with escape characters search. | API should return the correct results. | ||
TC38 | Verify API Response Content Type | Send API request to [Endpoint]. | The response should have the correct content type. | ||
TC39 | Verify API Response Compression (Accept-Encoding) | Send API request with “Accept-Encoding” header set to “gzip”. | The response should be compressed when the header is set. | ||
TC40 | Verify API Response Not Compressed | Send API request without “Accept-Encoding” header. | The response should not be compressed. | ||
TC41 | Verify API Response Not Compressed (Other Encoding) | Send API request with the “Accept-Encoding” header set to another value. | The response should not be compressed. | ||
TC42 | Verify API Response Language (Accept-Language) | Send API request with “Accept-Language” header for specific language. | The response should be in the specified language. | ||
TC43 | Verify API Response Locale | Send API request with “Locale” header for specific locale. | The response should be in the specified locale. | ||
TC44 | Verify API Response Timezone (Accept-Timezone) | Send API request with “Accept-Timezone” header for specific timezone. | The response should be in the specified timezone. | ||
TC45 | Verify API Response with Nested Objects/Arrays | Send API request to [Endpoint]. | The response should handle nested objects/arrays. |
Conclusion:
API testing is an important step in the development of any application. It’s important to test your APIs regularly, especially if you’re developing them for a mobile app. By automating these tests, you can ensure that your apps continue to work properly and provide the best possible user experience. To learn more about API testing, check out our blog post here. If you can think of more of these test cases, you can share them with us in the comment section.
Unable to see templete/example format of TCs
We have uploaded many sample test cases here
https://www.softwaretestingo.com/manual-test-cases-example/
https://www.softwaretestingo.com/manual-test-cases-example/ – in this API test case sample not available
Check You Check now we have added some common API Testing Test Cases
thank you its very usefull