Coder Social home page Coder Social logo

Comments (18)

rickflar avatar rickflar commented on July 24, 2024 4

Because it used to be in earlier versions - we used it to set up a custom folder for the results of the run.

from allure-gradle.

admizh avatar admizh commented on July 24, 2024 4

In this case - @rickflar if you need to use a working plugin with task customization, I mean - override default report outputs, disabling SPI OFF (), task aggregation - just not use the latest versions for Allure. Unfotunantliy you lose support for gradle 7 - because the last plugin changes/fixes not working in multiple places, not support manual customizations.

Currently, all work as expected with old versions of allure gradle plugin 2.8.1, gradle 6.9.1:

id("io.qameta.allure") version "2.8.1"
tasks.withType<Wrapper> {
  gradleVersion = "6.9.1"
  distributionType = Wrapper.DistributionType.ALL
}

@vlsi in my case (and many allure users) - we did not use autoconfiguration {} closure at all - we use allure extensions just to have proper API binding from gradle to allure command-line. Like this:

configure<AllureExtension> {
  version = `allure-version`
  autoconfigure = false
  aspectjweaver = false
  configuration = "testImplementation"
  reportDir = file(dynamic["allure.results.directory"].toStringOrEmpty())
}

val aggregatedReport by tasks.creating(AllureReport::class) {
  group = "e2e-allure"
  clean = true
  reportDir = file("${rootProject.buildDir}/allure-report")
  resultsDirs = subprojects.map {
    file("${it.buildDir}/allure-results")
    file("${it.projectDir}/allure-results")
  }.filter { it.exists() }
  resultsDirs.add(file("${rootProject.buildDir}/allure-results"))
}

tasks.withType<io.qameta.allure.gradle.task.AllureServe> {
  group = "e2e-allure"
  dependsOn("downloadAllure")
}

tasks.withType<io.qameta.allure.gradle.task.DownloadAllure> {
  group = "e2e-allure"
}

tasks.withType<AllureReport> {
  if (this.name == "allureReport") {
    this.enabled = false
    group = "deprecated"
  }
}

from allure-gradle.

vlsi avatar vlsi commented on July 24, 2024 2

The folder is not documented, so it can be changed.

from allure-gradle.

baev avatar baev commented on July 24, 2024 1

@vlsi can we provide a possibility to override output per task?

from allure-gradle.

re-l124c41 avatar re-l124c41 commented on July 24, 2024 1

Ended up using somewat hacky solution. It works with gradle 8.5, java 21, allure 2.25.0

  1. Add file src/test/resources/allure.properties.bak with text:
allure.results.directory=RESULT_DIR
  1. In build.gradle add task and configure task dependency:
task allureProperties(type: Copy) {
   outputs.upToDateWhen{ false }
   from file('src/test/resources/allure.properties.bak')
   into 'src/test/resources/'
   rename{ 'allure.properties' }
   filter{ line -> line.replace('RESULT_DIR', file(layout.buildDirectory.dir('allure-results')).toString()) }
}

processTestResources{
   dependsOn(tasks.allureProperties)
}

This task will copy content of bakup properties file to actual file and replace results directory value with absolute path.

If you don't care about other properties and need to set only result path, you can omit bakup file and simplify tasks to:

task allureProperties {
   outputs.upToDateWhen{ false }
   doFirst {
      def props = file('src/test/resources/allure.properties')
      props.write("allure.results.directory=${file(layout.buildDirectory.dir('allure-results'))}")
   }
}
processTestResources{
   dependsOn(tasks.allureProperties)
}

from allure-gradle.

nicolabeghin avatar nicolabeghin commented on July 24, 2024 1

Ended up using somewat hacky solution. It works with gradle 8.5, java 21, allure 2.25.0
If you don't care about other properties and need to set only result path, you can omit bakup file and simplify tasks to:

task allureProperties {
   outputs.upToDateWhen{ false }
   doFirst {
      def props = file('src/test/resources/allure.properties')
      props.write("allure.results.directory=${file(layout.buildDirectory.dir('allure-results'))}")
   }
}
processTestResources{
   dependsOn(tasks.allureProperties)
}

thanks a lot, hacky but does the trick!! kudos for coming up with that :D

from allure-gradle.

vlsi avatar vlsi commented on July 24, 2024

Why do you need it?

from allure-gradle.

vlsi avatar vlsi commented on July 24, 2024

The thing is there might be mulitple tasks (e.g. test, integrationTest, javaexec, etc) that collect Allure raw results.
That makes "single result folder" complicated.

from allure-gradle.

vlsi avatar vlsi commented on July 24, 2024

For instance, https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:task_input_output_parallelism

Gradle will inspect the outputs of tasks when selecting the next task to run and will avoid concurrent execution of tasks that write to the same output directory

from allure-gradle.

vlsi avatar vlsi commented on July 24, 2024

I would like to see an end-to-end use-case

from allure-gradle.

rickflar avatar rickflar commented on July 24, 2024

As i noticed, results appear in allure-results folder in build folder by default. So, it's the case of "single result folder", isn't it? Or without setting a resultsDir variable, results can appear in different folders?

For instance, https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:task_input_output_parallelism

Gradle will inspect the outputs of tasks when selecting the next task to run and will avoid concurrent execution of tasks that write to the same output directory

from allure-gradle.

admizh avatar admizh commented on July 24, 2024

@baev maybe you had the same case as mine in the previous comment? Can you help and advise us here? ... how we can create a correct working example with the latest gradle API + not-broken plugin. theoretically, I can just make direct calls to bat files...

from allure-gradle.

jacksonwen001 avatar jacksonwen001 commented on July 24, 2024

Does there are any solutions? We have this problem, I running test case in different environments but I wanna keep different results in different folder. such as if I specify -Denv=qa and results will place at build/projectName/qa/allure-results and I specify -Denv=prod and results will place at build/projectName/prod/allure-results. and the same as report. Any solutions can help?

from allure-gradle.

Leo-Lem avatar Leo-Lem commented on July 24, 2024

Has anyone found a solution to this problem? We're facing the same issue here...

from allure-gradle.

vlsi avatar vlsi commented on July 24, 2024

@Leo-Lem , would you please clarify what is your issue exactly?
What is your use case, and why do you need to customize the folder?

from allure-gradle.

Leo-Lem avatar Leo-Lem commented on July 24, 2024

Hey @vlsi, we are updating a mobile test automation framework with appium, gradle, testng, allure etc. Due to parallel test execution, we'd like to have separate "build" directories for each gradle build to avoid conflicts (in the format of 'out-timestamp' under a results directory). This works well enough (by specifying the project's buildDir in the build.gradle file), only the allure-results are always generated in root/build/allure-results.

We'd appreciate it if a custom allure results directory could be configured...

from allure-gradle.

re-l124c41 avatar re-l124c41 commented on July 24, 2024

In my case allure just fails to produce raw results with error: io.qameta.allure.AllureResultsWriteException: Could not write Allure test result container caused by FileNotFoundException.
Tried to setup results dir in allure.properties but error remains the same.
While debugging allure code i noticed that this.mapper.writeValue(file.toFile(), testResultContainer); fails if called in eval window as-is, but if a call it with file, resolved to absolute path: this.mapper.writeValue(new File(file.toAbsolutePath().toString), testResultContainer); it works just fine.
If I change path to directory in allure.properties to absolute path it works too.

from allure-gradle.

nicolabeghin avatar nicolabeghin commented on July 24, 2024

Any update on this? thanks!

from allure-gradle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.