Validation Testing
What is Validation Testing?
Validation Testing in API Testing means checking whether the API returns the correct response according to the expected requirements.
When we send a request to an API, we don’t just check whether we received a response. We need to verify whether that response is correct, complete, properly structured, and contains the expected data.
Validation Testing – Types
1. Status Code Validation
Checks whether the API returns the correct status code like 200, 201, 400, 401, or 404.
2. Response Body Validation
Checks whether the API returns the correct data in the response.
3. Header Validation
Checks whether the response contains the expected headers, such as Content-Type.
4. JSON Structure Validation
Checks whether the response has the correct JSON format and structure.
5. Required Field Validation
Checks whether all important and mandatory fields are present in the response.
6. Data Type Validation
Checks whether the returned data has the correct type, such as String, Number, or Boolean.
7. Field Value Validation
Checks whether the actual value matches the expected value.
8. Error Response Validation
Checks whether the API gives the correct status and error message when something goes wrong.
9. Business Rule Validation
Checks whether the API follows the actual rules of the application, such as checking balance before a bank withdrawal.
10. Null & Empty Validation
Checks whether important fields are unexpectedly null or empty.
Most Important Interview Questions
01. What is Validation Testing in API Testing?
Answer: Validation Testing checks whether an API returns the correct response according to the expected requirements. We verify the status code, response data, headers, fields, and overall response structure.
02. What do you validate in an API response?
Answer: We validate the status code, response body, headers, JSON structure, required fields, data types, field values, and error messages.
03. How do you validate API responses in Postman?
Answer: We send the API request in Postman and check the response. We can use Postman test scripts and assertions to automatically verify status codes, response data, headers, and other expected values.
04. What is the difference between positive and negative validation?
Answer: Positive validation checks whether the API works correctly with valid data. Negative validation checks whether the API handles invalid or incorrect data properly.
Example:
Valid password → 200 OK → Positive
Wrong password → 401 Unauthorized → Negative
05. How do you validate status codes and response data?
Answer: We compare the actual response with the expected result. For example, if a successful request should return 200 OK, we verify the status code is 200 and then check whether the response contains the correct data.