Contract Testing

Info Icon

INFO

Testing features are in early access. Breaking changes may occur.

Speakeasy enables you to verify API and SDK functionality by generating and running contract tests. Our solution scales from per-operation contract tests to end-to-end tests for validating any multi-step API user journey.

Design Philosophy

Similar to our SDK design philosophy, we strive to have best-in-class development experience for Contract testing as well:

  • Human readable - Generated tests are easy for developers to read and debug. We avoid convoluted abstractions.
  • Batteries-included - Generated tests for all SDK operations and a real API testing environment is optional. A generated mock API server works out of the box to avoid complex test environment setup, such as data seeding.
  • Rich coverage - Automatically generated contract tests verify all possible data fields to ensure full coverage. If data examples are not available, realistic example values for the field are used based on naming, type, and format information.
  • Customizable - Custom tests are supported beside generated tests.
  • Minimal dependencies - We start with native language libraries and layer on third-party libraries only when the customer benefits far outweigh the cost of the extra dependency. We avoid adding unnecessary dependencies.
  • Easy integration - Integrating our testing should fit into your existing API development and testing workflows.
  • Open standards - No vendor lock-in necessary.

Features

Speakeasy’s test generation uses the Arazzo Specification to generate tests for your API. Arazzo is a simple, human-readable, and extensible specification for defining API workflows. With Arazzo powering test generation, Speakeasy provides the following features:

  • Automatically generate contract tests for every operation in your OpenAPI specification.
    • A .speakeasy/tests.arazzo.yaml file is generated or modified to include tests for your operations.
    • Use examples available in your OpenAPI document or autogenerates examples based on the field name, type, and format of your schemas.
    • Generates a mock server capable of responding to the API requests, making the tests functional.
  • Define custom tests & workflows for any use case and define rich tests capable of:
    • Testing multiple operations.
    • Testing different inputs.
    • Validating the correct response is returned.
    • Run against a real API or mock server.
    • Configure setup and teardown routines for complex E2E tests.

Prerequisites

The following are requirements for enabling testing features:

Next Steps