Manuals / API Testing / Ch 4

B · Test DesignIntermediate55 min read

4. Negative tests & edge cases

API Testing · 44 pages source format

Happy paths are table stakes. Pro API testers ship negative cases: invalid payloads, missing auth, wrong methods, boundary values.

What you'll learn

  • Negative case categories
  • Error body assertions
  • Boundary testing

Negative categories

Invalid JSON, missing required fields, wrong types, unauthorized, forbidden, not found, method not allowed.

Do this now

Add 5 negative requests to collection. Assert 4xx status AND error message shape.

Clear?

Assert error contracts

Errors should be predictable: { "error": "...", "code": "..." }. Assert keys exist, not just status.

Do this now

Document expected error schema for 401 and 404 in ERROR-CONTRACTS.md.

Clear?

Boundary values

Empty string, max length, zero, negative numbers, special characters in strings.

Do this now

Test POST with empty title, 10k character body (if API allows), invalid email format.

Clear?

Test data isolation

Unique titles with timestamp prevent collisions. Delete in teardown or use disposable resources.

Do this now

Pre-request script: pm.environment.set("uniqueTitle", "post-" + Date.now());

Clear?

Checklist