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.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54
  • are you using configuration-on-demand? Do the test tasks on the root project and your subproject have the exact same name? – RaGe Jan 22 '16 at 18:16
  • I am not using "configuration on demand" feature and am using the default task name "test" in all project. Thanks. – Farrukh Najmi Jan 24 '16 at 22:47

1 Answers1

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
}
KKishore
  • 452
  • 5
  • 12
  • when i clean and run then it works, without clean it does not work, seems like an issue with gradle version – Manish Bansal Sep 23 '19 at 07:38
  • 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: https://stackoverflow.com/questions/29427020/how-to-run-gradle-test-when-all-tests-are-up-to-date – KKishore Sep 23 '19 at 11:27