Module: generator-template¶
generator-template provides the template generator: Mustache-based code generation for source-code tests (Java/Kotlin).
It is contributed as an explicit feature module (TemplateGeneratorModule) rather than being built-in to core.
Depends on¶
core
Used by¶
distribution-bundle(enabled by default viaDistributionDefaults)
Key types¶
TemplateGeneratorModule:TestGenerationModulethat registers thetemplategeneratorTemplateArtifactGenerator(internal): renders templates and writes files
Configuration¶
See:
API reference¶
- Local Dokka output:
docs/api/openapi.testgen.generator-template/index.html
Generator-Template Module¶
This document is non-normative and targets contributors. For core wiring, see test-suite-writer generator and architecture. For generator selection and configuration examples, see template generator.
Scope and responsibilities¶
generator-template provides Mustache-based code generation for test suites. It contributes a
single generator id template and loads templates from
generator-template/src/main/resources/templates.
Key types¶
TemplateGeneratorModule¶
TemplateGeneratorModule implements TestGenerationModule and registers the template generator
via TemplateArtifactGeneratorFactory.
TemplateArtifactGenerator¶
TemplateArtifactGenerator:
- Renders test classes and methods from Mustache templates.
- Writes output files using
outputFileNamePattern. - Supports custom template directories via
customTemplateDir. - Uses
templateVariablesto pass user-defined values into templates.
Generator options¶
Options are parsed by transformAndValidateTemplateOptions:
templateSet: template set id (defaultrestassured-java).classTemplatePath: Mustache class template path (defaulttemplates/{{templateSet}}/class.mustache).customTemplateDir: optional filesystem directory for custom templates.templateVariables: map of custom variables available in templates.outputFileExtension: file extension (default inferred from templateSet).outputFileNamePattern: output naming pattern (default{{className}}.{{outputFileExtension}}).writeMode:OVERWRITEorSKIP_IF_EXISTS.fileHeaderComment: optional header string prepended by templates.
Template variables used by the built-in templates include:
classSuffix(defaults toTestin code).methodPrefix,methodSuffix(defaults to empty strings).
Templates¶
Built-in template sets:
restassured-javarestassured-kotlin
Each set provides a class.mustache and method.mustache template.
Related docs¶
- Core module: core
- Template generator how-to: template generator