Tests are written against the OpenAPI spec before the service is built. This ensures the spec is complete and unambiguous. Tools like Dredd or Schemathesis generate test cases from the spec automatically.