Generate your first test suite (CLI)¶
This tutorial generates tests from an OpenAPI spec using the CLI.
1) Get the CLI¶
Install via npm (recommended):
Or run without installing:
For native binaries and building from source, see Installation.
Verify installation:
2) Generate template-based tests¶
openapi-testgen \
--spec-file path/to/openapi.yaml \
--output-dir ./build/generated-tests \
--generator template \
--generator-option templateSet=restassured-java \
--generator-option templateVariables.package=com.example.generated \
--generator-option templateVariables.baseUrl=http://localhost:8080
This generates Java test classes using RestAssured that you can run with JUnit.
3) Generate JSON/YAML test suites¶
For data-driven testing or custom frameworks:
openapi-testgen \
--spec-file path/to/openapi.yaml \
--output-dir ./build/out \
--generator test-suite-writer \
--generator-option outputFileName=openapi-test-suites.json
This generates a JSON file containing test case definitions that can be consumed by any test runner.
Next steps¶
- Learn how to interpret outputs: Understanding output
- Configure generation via YAML: YAML config
- Full CLI reference: CLI reference