Customizing SDK tests

Regenerate tests from scratch

By default, tests will only be populated from modifications to the tests.arazzo.yaml file once they have been bootstrapped.

To regenerate all SDK tests from scratch, run the following command:

speakeasy configure tests --rebuild

Disable autogeneration of tests for specific operations

If generateNewTests is enabled in the .speakeasy/gen.yaml file, any new operations detected in the next generation will automatically have workflows created for them in the .speakeasy/tests.arazzo.yaml file, and tests will be generated for them.

To disable the autogeneration of tests for specific operations, add the x-speakeasy-test extension to the operation in the OpenAPI document.

openapi: 3.1.0
# ...
paths:
/example1:
get:
x-speakeasy-test: false # Disables autogeneration of tests for this operation
# ...
# ...

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

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.

To configure which tests should be grouped in separate test files, add the x-speakeasy-test-group extension to the workflow.

arazzo: 1.0.0
# ...
workflows:
- workflowId: some-test
x-speakeasy-test-group: user # All tests in the user group will end up in the `user.test.ts`/`test_user.py`/`user_test.go` files
# ...

Generate tests only for specific targets

By default, all tests will be generated for all supported targets.

To generate tests only for specific targets, use the x-speakeasy-test-targets or x-speakeasy-test-targets-exclude extensions. This may be useful if tests are unnecessary for certain languages or are failing for a specific language.

arazzo: 1.0.0
# ...
workflows:
- workflowId: some-test
x-speakeasy-test-targets: # Only generate tests for the typescript target
- typescript
# ...

or

arazzo: 1.0.0
# ...
workflows:
- workflowId: some-test
x-speakeasy-test-targets-exclude: # generate tests for all languages except typescript
- typescript
# ...

Customizing SDK test manifests

Directly modifying SDK tests is not common, but you can 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