Search code examples
gradlejunitdeprecation-warning

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);
    }

Solution

  • 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