APIs are the most testable surface in modern systems — fast, deterministic, and CI-friendly. This guide shows how to build a production-grade API testing stack using Postman + Newman for teams without heavy Java investment, and REST Assured for Java teams that need first-class IDE integration.
What to test in an API
- Status codes (2xx success, 4xx client, 5xx server).
- Payload shape (JSON Schema).
- Auth (Bearer, OAuth, API keys).
- Pagination + filters.
- Rate limits + retry behaviour.
- Edge cases (empty, oversize, unicode, malformed).
Postman: collections, environments, scripts
Postman is the de-facto tool for API exploration and team-shared collections. Use environments for base URLs + auth tokens, pre-request scripts for token refresh, and tests for assertions. Newman runs collections in CI without the GUI.
REST Assured: Java DSL
Contract testing with Pact
Pact verifies the consumer-provider agreement without integration tests. The consumer defines expectations; the provider verifies them in its own CI. Catches breaking API changes before they reach production.
Mock servers for isolation
- Postman Mock — built into Postman, easy to share with the team.
- WireMock — Java, programmable, advanced scenarios.
- MSW (Mock Service Worker) — JS, intercepts in-browser fetch calls.