Question 5Medium
What does a contract test between a consumer and a provider API verify?
- That the server has enough free memory left on disk
- That both sides agree on the message format
- That the user interface colours match
- That the database is fully encrypted
Answer: B. That both sides agree on the message format
Explanation
Contract tests ensure the provider keeps responses that the consumer relies on.
Step-by-step solution
- Agree on format.
- Consumer needs fields.
- Provider must keep them.
Why the other options are wrong
- A. That's a capacity matter.
- C. UI is unrelated.
- D. Encryption is a security check.
Question 6Medium
In API testing, which part should be validated beyond the status code?
- Only the colour in which the response is shown
- Only the IP address of the server
- Nothing more, because the status code is sufficient
- Response body structure, data values and headers
Answer: D. Response body structure, data values and headers
Explanation
A good API test checks status, schema, field values, headers and error messages.
Step-by-step solution
- Status alone is insufficient.
- Check body.
- And headers.
Why the other options are wrong
- A. Colour is not relevant.
- B. Not a functional check.
- C. A 200 with wrong data is still a defect.
Question 8Hard
An API returns 200 OK with an error message in the body for invalid input. Which is the best assessment?
- Correct, 200 is always used for any kind of reply
- Correct, all errors should use a 5xx code
- Not testable with any API test
- A defect; invalid input should give a 4xx code
Answer: D. A defect; invalid input should give a 4xx code
Explanation
Invalid input is a client error, so 400 (or 422) is appropriate rather than a success code.
Step-by-step solution
- Invalid input is a client error.
- Needs 4xx.
- 200 is wrong.
Why the other options are wrong
- A. Status codes should reflect the outcome.
- B. 5xx means server faults, not client input.
- C. It is testable and wrong.