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.
plugins {
id("art.galushko.openapi-test-generator") version "0.8.0"
}
Finding the latest version
Check the Gradle Plugin Portal or GitHub Releases for the latest 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¶
./gradlew generateOpenApiTests
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:
openApiTestGenerator {
manualOnly.set(true)
}
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