### Single-module smoke example with Allure agent Source: https://github.com/allure-framework/allure-gradle/blob/main/docs/allure-agent-mode.md Uses a unique temp directory and expectations file per run. Runs the Allure agent against the allure-adapter-plugin module's test task. ```bash TMP_DIR="$(mktemp -d)" EXPECTATIONS="$TMP_DIR/expectations.yaml" ALLURE_AGENT_OUTPUT="$TMP_DIR/agent-output" \ ALLURE_AGENT_EXPECTATIONS="$EXPECTATIONS" \ allure run -- ./gradlew :allure-adapter-plugin:test ``` -------------------------------- ### Review-oriented expectations YAML example Source: https://github.com/allure-framework/allure-gradle/blob/main/docs/allure-agent-mode.md YAML is preferred for expectations in v1. This example defines a review goal with a task ID, expected label values, and notes for reviewing runtime evidence before source inspection. ```yaml goal: Review module tests task_id: module-review expected: label_values: module: allure-plugin notes: - Review runtime evidence before source inspection. ``` -------------------------------- ### Add raw result folders via allureRawResultElements configuration Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Use this to add externally produced or additional result folders. The example shows both `files()` syntaxes and how to attach a task-built artifact with `builtBy`. ```kotlin plugins { id("io.qameta.allure-adapter-base") } dependencies { allureRawResultElements(files(layout.buildDirectory.dir("custom-allure-results"))) // or allureRawResultElements(files("$buildDir/custom-allure-results")) } // If the results are built with a task, you might want adding a dependency so aggregate report // knows which tasks to run before building the report allureRawResultElements.outgoing.artifact(file("...")) { builtBy(customTask) } ``` -------------------------------- ### Add JUnit Platform Launcher as Test Runtime Dependency Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Add this dependency if your environment is missing JUnit Platform at test runtime. Some setups require this explicitly. ```groovy dependencies { testRuntimeOnly "org.junit.platform:junit-platform-launcher" } ``` -------------------------------- ### Spock 2 Test with Allure Attachments and Steps Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Example Spock 2 test that produces a single Allure attachment per executed test, mirroring the JUnit 4 sample. Uses @Step and @Attachment annotations. ```groovy import io.qameta.allure.Attachment import io.qameta.allure.Step import spock.lang.Specification class SpockTest extends Specification { def "example"() { when: stepMethod() then: true } @Step("step") void stepMethod() { attachment() } @Attachment(value = "attachment", type = "text/plain") String attachment() { "

HELLO

" } } ``` -------------------------------- ### Register Allure Karate listener in Java runner Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md For Karate 2, register the Allure listener explicitly in the runner; service-loader autoconfiguration is only available for Karate 1. This example uses `Runner.builder()` with a path and a parallel count. ```java Runner.builder() .path("classpath:features") .listener(new io.qameta.allure.karate.AllureKarate()) .parallel(4); ``` -------------------------------- ### Build aggregate report with allureAggregateServe Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Command to build and browse an aggregate Allure report. Requires applying the io.qameta.allure-aggregate-report plugin. ```bash ./gradlew allureAggregateServe ``` -------------------------------- ### Use local allure-commandline binary via allureCommandline configuration Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Resolve a local allure-commandline zip file by adding it to the allureCommandline configuration. Avoid relative paths because the current directory is not reliable in multi-threaded builds. ```kotlin dependencies { // allureCommandline must resolve to a single zip file // You could use regular Gradle syntax to specify the dependency allureCommandline(files("/path/to/allure-commandline.zip")) } ``` -------------------------------- ### Compact Gradle review pattern with Allure agent Source: https://github.com/allure-framework/allure-gradle/blob/main/docs/allure-agent-mode.md Uses a unique temp directory and expectations file per run. Runs the Allure agent against a specific Gradle test for the allure-plugin module. ```bash TMP_DIR="$(mktemp -d)" EXPECTATIONS="$TMP_DIR/expectations.yaml" ALLURE_AGENT_OUTPUT="$TMP_DIR/agent-output" \ ALLURE_AGENT_EXPECTATIONS="$EXPECTATIONS" \ allure run -- ./gradlew :allure-plugin:test --tests 'io.qameta.allure.gradle.report.AllurePluginFeatureMatrixTest' ``` -------------------------------- ### Basic configuration with Kotlin DSL Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Minimal configuration for the Allure Gradle plugin using Kotlin DSL. Applies the plugin and adds the Maven Central repository for adapter dependencies. ```kotlin plugins { id("io.qameta.allure") version "" } repositories { // Repository is needed for allure-java adapter dependencies. // The default Allure 3 report runtime is provisioned automatically. mavenCentral() } ``` -------------------------------- ### Basic configuration with Groovy DSL Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Minimal configuration for the Allure Gradle plugin using Groovy DSL. Applies the plugin and adds the Maven Central repository for adapter dependencies. ```groovy plugins { id'io.qameta.allure' version '' } repositories { // Repository is needed for allure-java adapter dependencies. // The default Allure 3 report runtime is provisioned automatically. mavenCentral() } ``` -------------------------------- ### Apply allure-report plugin Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Apply the `io.qameta.allure-report` Gradle plugin to enable report generation tasks. ```kotlin plugins { id("io.qameta.allure-report") } ``` -------------------------------- ### Apply aggregate report plugin in root project Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Apply the `io.qameta.allure-aggregate-report` plugin in the parent project to aggregate raw results from submodules. Add repositories for adapter/test dependencies if needed. ```kotlin plugin { id("io.qameta.allure-aggregate-report") } // Add repositories for adapter/test dependencies if the aggregated projects need them. repositories { mavenCentral() } ``` -------------------------------- ### Run allureReport with single-file option Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Enable single-file report generation for a single invocation without changing the DSL. ```bash ./gradlew allureReport --single-file=true ``` -------------------------------- ### Configure Allure adapter in submodule Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Apply the `io.qameta.allure-adapter` plugin and configure the Jupiter framework in a submodule to collect raw Allure results automatically for each Test task. ```kotlin plugin { `java-library` id("io.qameta.allure-adapter") } allure { adapter { frameworks { jupiter } } } // Each Test task will write raw data for Allure automatically ``` -------------------------------- ### Build report and execute tests with allureReport --depends-on-tests Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Command to execute tests and build the Allure report. Use this to run tests before report generation. ```bash ./gradlew allureReport --depends-on-tests ``` -------------------------------- ### Configure Allure adapter with Kotlin DSL Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Use this snippet to customize data collection in the io.qameta.allure-adapter Gradle plugin. The values shown are defaults; in Groovy DSL, use `allureJavaVersion = "2.35.5"` instead. It sets adapter versions, environment variables, autoconfiguration flags, categories file, results directory, and framework-specific settings. ```kotlin allure { version.set("3.14.3") adapter { // Configure version for io.qameta.allure:allure-* adapters // The default stays on 2.x; set 3.0.0 to opt into Allure Java 3 allureJavaVersion.set("2.35.5") aspectjVersion.set("1.9.25") // Customize environment variables for launching Allure environment.put("JAVA_HOME", "/path/to/java_home") autoconfigure.set(true) autoconfigureListeners.set(true) autoconfigureJavadocDescriptions.set(true) aspectjWeaver.set(true) // By default, categories.json is detected in src/test/resources/../categories.json, // However, it would be better to put the file in a well-known location and configure it explicitly categoriesFile.set(layout.projectDirectory.file("config/allure/categories.json")) // Customize where adapter-managed test tasks write raw Allure results resultsDir.set(layout.buildDirectory.dir("custom-allure-results")) frameworks { junit4 { adapterVersion.set("...") enabled.set(true) } jupiter { // Defaults to allureJavaVersion adapterVersion.set("...") enabled.set(true) // Enables allure-jupiter default test listeners via META-INF/services/... autoconfigureListeners.set(true) } junitPlatform { autoconfigureListeners.set(true) } testng { adapterVersion.set("...") enabled.set(true) autoconfigureListeners.set(true) } assertj jbehave // Deprecated: JBehave 4, Allure Java 2.x only jbehave5 karate { autoconfigureListeners.set(true) } scalatest spock cucumber4Jvm // Deprecated: Allure Java 2.x only cucumber5Jvm // Deprecated: Allure Java 2.x only cucumber6Jvm // Deprecated: Allure Java 2.x only cucumber7Jvm } } } ``` -------------------------------- ### Add externally produced result folders via allureReport dependency Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md For report-only projects that do not apply `io.qameta.allure-adapter`, configure the report input using the `allureReport` configuration. ```kotlin dependencies { allureReport(files(layout.buildDirectory.dir("custom-allure-results"))) } ``` -------------------------------- ### Run allureReport with config-file option Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Use a custom Allure 3 config file for a single invocation. The Gradle task still passes its `reportDir` as `--output`. ```bash ./gradlew allureReport --config-file=allurerc.mjs ``` -------------------------------- ### Build and browse report with allureServe Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Command to build and browse the Allure report. By default, allureServe does not execute tests. ```bash ./gradlew allureServe ``` -------------------------------- ### Enable JUnit Platform for Spock 2 (Groovy DSL) Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Required for Spock 2.x tests to run on JUnit Platform. Add this to your test task configuration in the Groovy DSL. ```groovy test { useJUnitPlatform() } ``` -------------------------------- ### Configure custom allure-commandline download URL and coordinates Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Configure the Allure 2 commandline download when using a customized distribution. Set allure.version to a 2.x release and optionally set downloadUrlPattern, group, module, and extension. If downloadUrlPattern is set, an extra ivy repository is configured with exclusive content filtering on Gradle 6.2+. ```kotlin allure { // Legacy runtime selection. version.set("2.42.1") commandline { // The following patterns are supported: `[group]`, `[module]`, `[version]`, `[extension]` // The patterns can appear severs times if you need // By default, downloadUrlPattern is NOT set. downloadUrlPattern.set("https://server/path/[group]/[module]-[version].[extension]") // groupId for allure-commandline group.set("io.qameta.allure") // module for allure-commandline module.set("allure-commandline") // extension for allure-commandline extension.set("zip") } } ``` -------------------------------- ### Customize report folder and single-file mode Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Configure the base directory for Allure reports and enable single-file report generation. The `reportDir` is a base directory; each task creates its own subfolder. ```kotlin plugins { id("io.qameta.allure-report") // the plugin is packaged with Gradle by default } // See https://docs.gradle.org/current/dsl/org.gradle.api.reporting.ReportingExtension.html // Extension is provided via Gradle's `reporting-base` plugin reporting { baseDir = "$buildDir/reports" } allure { report { // There might be several tasks producing the report, so the property // configures a base directory for all the reports // Each task creates its own subfolder there reportDir.set(project.reporting.baseDirectory.dir("allure-report")) // Enable single-file report generation. singleFile = true } } ``` -------------------------------- ### Configure Allure 3 custom config file Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Set a custom Allure 3 config file (e.g., `allurerc.mjs`) to configure environments, grouping, report name, or theme. When set, Allure 3-specific options like `singleFile` are ignored by Gradle. ```kotlin allure { report { configFile.set(layout.projectDirectory.file("allurerc.mjs")) } } ``` -------------------------------- ### Customize aggregate report module set Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md By default, `io.qameta.allure-aggregate-report` aggregates results from `allprojects`. Use these configurations to exclude a module, clear the default dependencies, or add a custom dependency. ```kotlin // By default, aggregate-report aggregates allprojects (current + subprojects) // So we want to exclude module3 since it has no data for Allure configurations.allureAggregateReport.dependencies.remove( project.dependencies.register(project(":module3")) ) // Removing the default allprojects: configurations.allureAggregateReport.dependencies.clear() // Adding a custom dependency dependencies { allureAggregateReport(project(":module3")) } ``` -------------------------------- ### Configure custom results directory for adapter-managed tasks Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Use this to change where adapter-managed test tasks write raw results. Configure `allure.adapter.resultsDir` in the `allure` block. ```kotlin allure { adapter { resultsDir.set(layout.buildDirectory.dir("custom-allure-results")) } } ``` -------------------------------- ### Disable default listeners for Jupiter and TestNG Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Alternative syntax to disable default listeners for multiple frameworks. Note that mentioning an adapter adds it to the classpath, so avoid unused adapters. ```kotlin allure { adapter { frameworks { // Note: every time you mention an adapter, it is added to the classpath, // so refrain from mentioning unused adapters here jupiter { // Disable allure-jupiter default test listeners autoconfigureListeners.set(false) } testng { // Disable allure-testng default test listeners autoconfigureListeners.set(false) } } } } ``` -------------------------------- ### Configuring Allure version with Groovy DSL Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Sets the Allure version to 3.14.3 using Groovy DSL. The version selects the report runtime family: 3.x uses the default Allure 3 runtime, 2.x uses the Allure 2 commandline zip. ```groovy allure { version = "3.14.3" } ``` -------------------------------- ### Configure dependsOnTests for allureReport Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Set `dependsOnTests` to true so `allureReport` always executes tests before generating the report. By default, `allureReport` does NOT execute tests. ```kotlin allure { report { // By default, allureReport will NOT execute tests // If the tests are fast (e.g. UP-TO-DATE or FROM-CACHE), // then you might want configure dependsOnTests.set(true) so you always // get the latest report from allureReport dependsOnTests.set(true) } } ``` -------------------------------- ### Disable automatic Javadoc description processing Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Disables the automatic addition of `io.qameta.allure:allure-descriptions-javadoc` to annotation processor configurations. ```kotlin allure.adapter.autoconfigureJavadocDescriptions.set(false) ``` -------------------------------- ### Set Allure Java version to 3.0.0 in Kotlin DSL Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Use this Kotlin DSL configuration to migrate a project to Allure Java 3. The default remains Allure Java 2.35.5. Changing `allureJavaVersion` does not affect the report generator version, which is controlled by `allure.version`. ```kotlin allure { adapter { allureJavaVersion.set("3.0.0") } } ``` -------------------------------- ### Disable default JUnit Jupiter listeners Source: https://github.com/allure-framework/allure-gradle/blob/main/README.md Disables the default JUnit Jupiter listeners provided by `allure-java`. ```kotlin allure.adapter.frameworks.jupiter.autoconfigureListeners.set(false) ```