Gradle integration¶
This tutorial integrates test generation into a Gradle project using the plugin.
1) Apply the plugin¶
The plugin is published to the Gradle Plugin Portal.
Finding the latest version
See Version placeholders for where to look up <version>.
2) Configure the extension¶
Minimal template generator configuration:
openApiTestGenerator {
specFile.set("src/test/resources/openapi.yaml")
outputDir.set(layout.buildDirectory.dir("generated/openapi-tests"))
generator.set("template")
generatorOptions.putAll(
mapOf(
"templateSet" to "restassured-java",
"templateVariables" to mapOf(
"package" to "com.example.generated",
"baseUrl" to "http://localhost:8080",
),
)
)
}
3) Run generation¶
The generated tests will be automatically added to your test source set.
4) Manual-only mode (optional)¶
To disable automatic wiring into compilation/resource processing:
Use this when you need custom control over when and how generated sources are included.
Next steps¶
- Generator configuration details: Template generator
- Reference for all DSL fields: Gradle plugin reference
- All available settings: Distribution settings