Multiproject build: separate Junit tests with common test-results-dir


(srimugunthan) #1

Hi,
I am using Gradle-2.3 and have a build system which is like what is shared in the following github directory


In the shared repo there are three projects ,“projectA”, “projectB”, “projectC”. The Junit test for projectA is in “${rootProject.projectDir}/test” directory while projectB has no Junit tests.

In the root build.gradle, to generate all build and test output in the same directory, i have
"
subprojects {
apply plugin: ‘java’

   buildDir = new File(file("$rootDir"), "release_tmp/")
  testResultsDirName= 'test-results'

}
"

But with this build configuration, when i do
"gradle projectB:test"

projectA’s test is being run.
How do i avoid this?
Ideally gradle projectB:test should do nothing and only gradle projectA:test should run the projectA’s test,


(Schalk Cronjé) #2

It is becasue you are writing all of the output of all 3 subprojects into the same folder. The default behaviour of Gradle is to execute all the .class files it will find in classes/test/**. You can control what you needs to be executed, but you will need to configure eacth test task in each subproject seperately. Check the documentation in for the Test task type.