Q27 of 38 · Test design
How does test design differ for an API endpoint versus a UI form for the same feature?
Short answer
Short answer: API tests go directly to the contract — request shapes, status codes, response bodies, error payloads. UI tests add rendering, validation messaging, accessibility, and user interaction flow on top. API tests can cover more variations faster; UI tests verify the complete user experience.
Detail
For a 'create user' feature, the API test design covers: valid payloads (each required field, optional fields), invalid payloads (missing required fields, wrong types, boundary values), duplicate email, concurrent requests, authentication failures, and correct HTTP status codes (201, 400, 409, 401).
The UI test design adds: form validation messages appear in the right place, required field indicators, client-side validation fires before the API call, the success state renders correctly, and error responses from the API surface as readable messages rather than stack traces.
The principle: push as much variation testing as possible to the API layer where it is faster and more reliable. Use the UI layer for the happy path, key error states, and tests that specifically verify the presentation — not for exhaustive input boundary testing.