What is the difference between positive and negative API testing? Give examples.
- positive testing
- negative testing
- edge cases
Answer it first, then compare. Nothing here is saved or scored.
Model answer
Positive testing verifies the API works correctly with valid inputs: creating a user with all required fields returns 201. Negative testing verifies graceful handling of invalid inputs: missing required fields (400), invalid email format (422), SQL injection strings (400, not 500), extremely long strings (400), wrong data types (422). A thorough API test suite has more negative tests than positive, the happy path is one path, but there are many ways to fail.
What interviewers listen for
- Schema-first thinkingYou validate response shape before you assert on values, every time.
- Status-code literacyYou can defend why 401 vs 403 vs 422 matters for the consumer.
- Contract awarenessYou know when consumer-driven contract tests beat end-to-end checks.
- Auth fluencyYou can describe rotating tokens across parallel workers without secrets in logs.