Customizing SDK tests
Regenerate tests from scratch
By default, tests are only 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 automatically have workflows created for them in the .speakeasy/tests.arazzo.yaml
file, and tests are 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 is created for the operation.
Grouping tests
By default, all tests are 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-testx-speakeasy-test-group: user # All tests in the user group end up in the `user.test.ts`/`test_user.py`/`user_test.go` files# ...
Generate tests only for specific targets
By default, all tests are 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 is useful if tests are unnecessary for certain languages or are failing for a specific language.
arazzo: 1.0.0# ...workflows:- workflowId: some-testx-speakeasy-test-targets: # Only generate tests for the typescript target- typescript# ...
or
arazzo: 1.0.0# ...workflows:- workflowId: some-testx-speakeasy-test-targets-exclude: # generate tests for all languages except typescript- typescript# ...
Customizing SDK test manifests
Directly modifying SDK tests is not common, but the actual content of an existing SDK test can be customized by modifying the .speakeasy/tests.arazzo.yaml
file.
To learn more about these kinds of modifications see here.