Combine reports from existing Gradle reports

Hi,

I have a gradle reports(HTML based) generated and available in a zip archive. Is there a way in gradle where I can provide a list of archived reports and generate one consolidated report. To use gradle task I have to have them as subprojects which I do not and to use ant Junit task to aggregate reports, I have the reports in Gradle HTML format. So I am not sure what the solution might be. ANT might be right solution for this but I have not seen any solution so far.

Appreciate your time for reading this post, please let me know if you solution.

From the Test task docs

File binResultsDir

The root folder for the test results in internal binary format.

And from the TestReport task docs

FileCollection testResultDirs

The set of binary test results to include in the report

I’m guessing that you could take the binResultsDir from multiple Test tasks and feed them into a single TestReport task

Thank you very much, this solved my problem. Here is the code that worked for me. I just copied all the binary directories to a folder and then run the below task.

task genReport(type: TestReport) {

destinationDir = file("$buildDir/reports")

    def resultsdir = getProperty("resultsdir")
    ArrayList results = new ArrayList();

    file(resultsdir).eachDir { dirname ->
        results.add(new File(dirname.toString() + File.separator +  "binary"))
    reportOn results

}

I was thinking it would be something like the following (in groovy):

task genReport(type: TestReport) {
   def testTasks = allprojects.collect { it.tasks.withType(Test) }.flattern()
   mustRunAfter testTasks
   reportOn testTasks
} 

Lance,

This is a consolidation task and I do not need to run any tests. So I have a folder with all the test results that were run on the remote machines and all I am doing here is pointing to that folder which has the binary files and provide me a consolidated report.

FYI, I’ve solved this problem using the following subprojects config in my root project build.gradle file. This way no extra tasks are needed.

Note: this places each module’s output in its own reports/<module_name> folder, so subproject builds don’t overwrite each other’s results.

subprojects {
 // Combine all build results
  java {
    reporting.baseDir = "${rootProject.buildDir.path}/reports/${project.name}"
  }
}

Alternatively, you can merge Gradle unit test HTML reports for all subprojects into a single index.html file placing the following in your root build.gradle file.

task testReport(type: TestReport) {
  destinationDir = file("$buildDir/reports/allTests")
  // Combine all 'test' task results into a single HTML report
  reportOn subprojects.collect { it.tasks.withType(Test) }
}

This results should be available at build/reports/allTests/index.html

Thanks twiatedpair.
Could you please help me a more to incorporate this into my test.
I am using .csv file to write passed/fail once a test case is executed. what should i change in this to generate html report having total no. of test cases, passed and failed count.
What changes are required in this line:
subprojects.collect { it.tasks.withType(Test)}
As of now, it didn’t generate any report in this location.