Novaterata
Novaterata

Reputation: 4809

testReport destinationDir is deprecated in gradle 7.4.2 so how to set it?

task<TestReport>("testReport") {
    destinationDir = file("$buildDir/reports/allTests")
}

This is apparently deprecated, but the deprecation message doesn't make sense to me in this context. How am I actually supposed to set this value now?

    /**
     * Sets the directory to write the HTML report to.
     *
     * <strong>This method will be {@code @Deprecated} soon, please use {@link #getTestResults()} instead to access the new collection property.</strong>
     */
    public void setDestinationDir(File destinationDir) {
        DeprecationLogger.deprecateProperty(TestReport.class, "destinationDir").replaceWith("destinationDirectory")
            .willBeRemovedInGradle8()
            .withDslReference()
            .nagUser();
        getDestinationDirectory().set(destinationDir);
    }

Upvotes: 5

Views: 4135

Answers (2)

dbaltor
dbaltor

Reputation: 3383

$buildDir has also been deprecated but the good news is that you can collect all your subproject's test reports using test-report-aggregation plugin.

In Gradle 8.5, I've removed the following snippet from my parent build.gradle:

task testReport(type: TestReport) {
    destinationDir = file("./reports/allTests")
    // Include the results from the `test` task in all subprojects
    reportOn subprojects*.test
}

and created a separate subproject, say test-results, with the following build.gradle:

plugins {
     id 'base'
     id 'test-report-aggregation'
}

dependencies {
     testReportAggregation project(':subprojectA')
     testReportAggregation project(':subprojectB')
     testReportAggregation project(':subprojectN')
}

reporting.baseDir = "../reports/allTests"

test.finalizedBy('testAggregateTestReport')

run.enabled = false

Upvotes: 0

patnala ganesh
patnala ganesh

Reputation: 136

Please try like this.

Older version:

destinationDir = file("$buildDir/reports/tests/test")

With latest version:

getDestinationDirectory().set(file("$buildDir/reports/tests/test"))

It worked for me. Hope it'll work for you. Thanks

Upvotes: 12

Related Questions