Workflow Testing

Test an API Endpoint

Workflow for writing comprehensive API endpoint tests

testingapibackend
CLAUDE.md

When testing an API endpoint:

  1. Test the happy path: send a valid request, verify the correct status code and response body.
  2. Test input validation: send missing fields, wrong types, empty strings — verify 400 responses with helpful error messages.
  3. Test authentication: send a request without auth — verify 401. Send with invalid auth — verify 401.
  4. Test authorization: send a request as a user without permission — verify 403.
  5. Test not found: request a non-existent resource — verify 404.
  6. Test idempotency: send the same request twice and verify the behavior is correct.
  7. Test edge cases: very long strings, special characters, large payloads, concurrent requests.

Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.

get crystl