Speakeasy Logo
Skip to Content

Customizing SDK Tests

Test Generation Overview

When generateNewTests is enabled in the .speakeasy/gen.yaml file, workflows for any newly discovered operations will automatically be created in the .speakeasy/tests.arazzo.yaml file during the next generation. Tests will then be generated based on these workflows.

Note that for tests to actually be generated during speakeasy run, the generateTests setting must also be enabled. Both settings can be enabled by running speakeasy configure tests.

Disable auto generation of tests for specific operations

To disable auto generation of tests for specific operations, the x-speakeasy-test extension can be added to the operation in the OpenAPI document:

Alternatively, if a workflow/test already exists that references the operation in the .speakeasy/tests.arazzo.yaml file, then no new workflow will be created for the operation.

Automatic Test Synchronization

Speakeasy synchronizes workflows in the .speakeasy/tests.arazzo.yaml file based on the presence of the x-speakeasy-test-rebuild extension. When generateNewTests is enabled, Speakeasy automatically applies this extension to newly created workflows. The extension indicates that the workflows should remain synchronized with any subsequent changes to the OpenAPI specification.

Auto-sync with OpenAPI Changes (x-speakeasy-test-rebuild: true)

When set to true, the workflow will automatically be kept in sync with the state of the operation in the OpenAPI specification. The test will be rebuilt each time the spec changes, incorporating:

  • New parameters
  • Request body field changes
  • Response body updates
  • Updates to examples

This is useful if you want Speakeasy to automatically maintain your tests as your API evolves.

Manual Test Maintenance (x-speakeasy-test-rebuild: false or omitted)

When the extension is omitted or set to false, the workflow needs to be maintained manually and won’t sync with the OpenAPI specification. This gives you complete control over the test content and is useful when:

  • Writing custom tests with specific logic
  • Maintaining test state independent from the OpenAPI document
  • Catching breaking changes or regressions in the API behavior

Grouping tests

By default, all tests will be generated into a single file related to the main SDK class for example sdk.test.ts , test_sdk.py, or SDKTest.java. This can be configured by adding a x-speakeasy-test-group extension to the workflow which will determine which tests will be grouped together in seperate test files.

Generate tests only for specific targets

By default, all tests will be generated for all supported targets. Using the x-speakeasy-test-targets or x-speakeasy-test-targets-exclude extensions, it is possible to generate tests only for specific targets. This may be useful if tests are either not needed for certain languages or they may be failing in a certain language.

or

Customizing SDK Test Manifests

Directly modifying SDK tests is not common, but it is possible to customize the actual content of an existing SDK test by modifying the .speakeasy/tests.arazzo.yaml file. To learn more about these kinds of modifications see here.

Next Steps

Last updated on