在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):allure-framework/allure-gradle开源软件地址(OpenSource Url):https://github.com/allure-framework/allure-gradle开源编程语言(OpenSource Language):Kotlin 81.6%开源软件介绍(OpenSource Introduction):Allure plugin for GradleGradle projects plugins for building Allure reports for TestNG, JUnit4, JUnit5, Cucumber JVM, and Spock tests. Basic usage
Data colecting and reporting are split to different Gradle plugins, so you could apply the ones you need. Note: 2.9+ requires Gradle 5.0+ The minimal configuration is as follows.
It would configure test tasks to collect Allure results and add Groovy DSL: plugins {
id'io.qameta.allure' version '<latest>'
}
repositories {
// Repository is needed for downloading allure-commandline for building the report
mavenCentral()
} Kotlin DSL: plugins {
id("io.qameta.allure") version "<latest>"
}
repositories {
// Repository is needed for downloading allure-commandline for building the report
mavenCentral()
}
Configuring Allure versionGroovy DSL: allure {
value = "2.8.0"
} Kotlin DSL: allure {
value.set("2.8.0")
} Building Allure reportTo build a report, and browse it use the following command:
Note: by default,
To build an aggregate report, and browse it, apply
If you need a report only, please use By default, Customizing data collectingData collecting is implemented via The values in the sample below are the defaults.
The sample uses Kotlin DSL. In Groovy DSL you could use allure {
adapter {
// Configure version for io.qameta.allure:allure-* adapters
allureJavaVersion.set("2.13.9")
aspectjVersion.set("1.9.5")
autoconfigure.set(true)
autoconfigureListeners.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"))
frameworks {
junit5 {
// Defaults to allureJavaVersion
adapterVersion.set("...")
enabled.set(true)
// Enables allure-junit4 default test listeners via META-INF/services/...
autoconfigureListeners.set(true)
}
junit4 {
// same as junit5
}
testng {
// same as junit5
}
spock
cucumberJvm
// Alternative syntax: cucumberJvm(2) {...}
cucumber2Jvm
cucumber3Jvm
cucumber4Jvm
cucumber5Jvm
cucumber6Jvm
}
}
} What if I have both JUnit5, JUnit4, and CucumberJVM on the classpath?By default, Adding custom results for reportingYou could add a folder with custom results via 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)
} Using custom JUnit5 listeners instead of the default ones
Here's how you disable default listeners: allure.adapter.frameworks.junit5.autoconfigureListeners.set(false) An alternative syntax is as follows: allure {
adapter {
frameworks {
// Note: every time you mention an adapter, it is added to the classpath,
// so refrain from mentioning unused adapters here
junit5 {
// Disable allure-junit5 default test listeners
autoconfigureListeners.set(false)
}
testng {
// Disable allure-testng default test listeners
autoconfigureListeners.set(false)
}
}
}
} Report generationAggregating results from multiple projectsSuppose you have a couple of modules // Each submodule
plugin {
`java-library`
id("io.qameta.allure-adapter")
}
allure {
adapter {
frameworks {
junit5
}
}
}
// Each Test task will write raw data for Allure automatically Here's how you can aggregate that in their parent project (e.g.
plugin {
id("io.qameta.allure-aggregate-report")
}
// allure-aggregate-report requires allure-commandline, so we need a repository here
repositories {
mavenCentral()
} Browse report:
By default // 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.create(project(":module3"))
)
// Removing the default allprojects:
configurations.allureAggregateReport.dependencies.clear()
// Adding a custom dependency
dependencies {
allureAggregateReport(project(":module3"))
} Customizing report foldersReport generation is implemented via plugins {
id("io.qameta.allure-report")
} By default, the report is produced into Gradle's default reporting folder under $buildDir/reports/allure-report/allureReport $buildDir/reports/allure-report/allureAggregateReport You could adjust the default location as follows: 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"))
}
} Running tests before building the reportBy default,
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(false)
}
} Customizing allure-commandline downloadAllure download is handled with By default The plugin receives If you have a customized version, you could configure it as follows: allure {
// This configures the common Allure version, so it is used for commandline as well
version.set("2.8.0")
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")
}
} Note: if you configure If you use Gradle 6.2+, then the custom repository is configured with If you use Gradle 5.1+, then the repository would be configured with regular filtering, so it would be slightly less secure and slightly less efficient. Using local allure-commandline binary
Remember: NEVER use relative paths in your build files since "current directory" does not exist in a multi-threaded project execution (see https://youtrack.jetbrains.com/issue/IDEA-265203#focus=Comments-27-4795223.0-0). 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"))
} Technical detailsio.qameta.allure-base pluginExtensions:
io.qameta.allure-adapter-base pluginExtensions:
Configurations:
Tasks:
io.qameta.allure-adapter pluginConfigures automatic collectint of raw data from test tasks, adds Configurations:
io.qameta.allure-download pluginDownloads and unpacks Extensions:
Configurations:
Tasks:
io.qameta.allure-report-base pluginApplies Extensions:
io.qameta.allure-report pluginBuilds Allure report for the current project. Configurations:
Tasks:
io.qameta.allure-aggregate-report pluginBuilds Allure aggregate report. Configurations:
Tasks:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论