API testing

Add contract tests to the pipeline

Hard120 pts~45 min
  • Contract testing
  • CI gates
Practice app · Acme REST API

A live REST + GraphQL API with auth, validation, pagination, rate limiting and an interactive request console.

BASE_URL
/api/practice
Console app
/lab/api-testing-add-contract-tests-to-the-pipeline

Your starter code already declares BASE_URL — call the API relative to it.

Objective

Write a contract suite that validates the list, item and error shapes so a pipeline can gate on it.

Your task

  1. 1GET BASE_URL + "/users?limit=5" and validate the envelope and every item against the User schema.
  2. 2GET BASE_URL + "/users/1" and validate the same schema.
  3. 3GET BASE_URL + "/users/9999" and validate the error envelope { error: { code, message } }.

Acceptance criteria

  • GET /users and GET /users/1 return 200
  • GET /users/{id} returns 404
  • Schema validation is used
  • At least 3 assertions pass

Fixtures

apiKey
tqa_live_key_123
basicUser
admin
basicPassword
secret
username
qa@target.dev
password
Test@123

API testing · API Testing · Integration, performance & CI