Running test task on gradle root project does not run test task on subprojects
Asked Answered
G

1

9

In my multiproject I am running test task on root project and expecting that it will run test task on subprojects and produce a single test report. What I observe is that it never runs test task on subprojects. Is my expectation incorrect" DO I need to do any special configuration in my gradle scripts?

Note that I have no tests in my root project.

Gredel answered 22/1, 2016 at 17:59 Comment(2)
are you using configuration-on-demand? Do the test tasks on the root project and your subproject have the exact same name?Argufy
I am not using "configuration on demand" feature and am using the default task name "test" in all project. Thanks.Gredel
S
5

I think, this snippet from Gradle User Guide should help you out:

subprojects {
    apply plugin: 'java'

    // Disable the test report for the individual test task
    test {
        reports.html.enabled = false
    }
}

task testReport(type: TestReport) {
    destinationDir = file("$buildDir/reports/allTests")
    // Include the results from the `test` task in all subprojects
    reportOn subprojects*.test
}
Safir answered 25/1, 2016 at 19:3 Comment(2)
when i clean and run then it works, without clean it does not work, seems like an issue with gradle versionRosana
If the inputs and outputs of a Gradle task aren't changed, the default behavior of Gradle is to not rerun the task. So, if you try to rerun the test task without changing anything e.g. the source files, it won't be rerun. When you clean the project, you are basically removing the compiled class files, which the test task depends upon and therefore Gradle reruns the task. You can explicitly ask Gradle to rerun the tasks as described here: #29427520Safir

© 2022 - 2024 — McMap. All rights reserved.