I've got a multi-module android project, with unit tests distributed out amongst the various library modules. I've added the io.qameta.allure-adapter
plugin to my app module, and all my library modules, and my top-level module has the io.qameta.allure-aggregate-report
plugin applied. When I run :allureAggregateReport
however I get a bunch of errors about missing configurations:
> Could not resolve all task dependencies for configuration ':allureGenerateCategories'.
> Could not resolve project :core.
Required by:
project :
> No matching configuration of project :core was found. The consumer was configured to find attribute 'io.qameta.allure' with value 'COPY_CATEGORIES' but:
- None of the consumable configurations have attributes.
> Could not resolve project :feature.
Required by:
project :
> No matching configuration of project :feature was found. The consumer was configured to find attribute 'io.qameta.allure' with value 'COPY_CATEGORIES' but:
- None of the consumable configurations have attributes.
> Could not resolve project :onscene.
Required by:
project :
> The consumer was configured to find attribute 'io.qameta.allure' with value 'COPY_CATEGORIES'. However we cannot choose between the following variants of project :onscene:
- devDebugRuntimeElements
- devReleaseRuntimeElements
- flankDebugRuntimeElements
- prodDebugRuntimeElements
- prodReleaseRuntimeElements
- qaDebugRuntimeElements
- qaReleaseRuntimeElements
All of them match the consumer attributes:
....
Is there any way to get this working?
So, aggregation appears to not be the way to go here.
With allure already working in my test module, I added allure to my library projects. When I run the tests, it generates build/allure-results
for each of my modules.
I then finalize the testDebugUnitTest
task in my library projects with a task that renames the build/allure-results
to add the module as a prefix.
project.tasks.register("copyAllureResults", Copy::class) {
from(project.layout.buildDirectory.dir("allure-results"))
into(project.layout.buildDirectory.dir(
"${project.path.substring(1).replace(":","_")}-allure-results"
))
}
project.afterEvaluate {
tasks.getByName("testDebugUnitTest") {
finalizedBy("copyAllureResults")
}
}
Then in my test project, in my dependencies {}
, I do:
Files.walk(
Paths.get(project.rootProject.projectDir.absolutePath)
).filter {
it.isDirectory() && it.name.endsWith("-allure-results")
}.forEach {
logger.debug("Adding Allure Suite: ${it.name}")
allureRawResultElements(files("${it.absolutePathString()}"))
}
This adds the results for each module as a separate suite when I run :test:allureReport
. The only downside is that testDebugUnitTest
has to be run as a separate ./gradlew
command, so that the -allure-results folders exist during the configuration when :test:allureReport
is run.