I have 2 modules: A and B.
-A is a standalone module. Its tests run just fine all by itself.
-B is a dependent module. Its tests require a certain file in A's test folder (one test file in B extends one in A)
Here are what I believe to be the relevant parts of B's build.gradle
:
android {
...
sourceSets {
test.java.srcDirs += "../A/src/test/java"
}
}
dependencies {
compile project(':A')
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'org.mockito:mockito-core:1.9.5'
}
While this technically works for what I need it - it has the nasty side effect that whenever I run A's unit tests, they also run all of B's tests. I would really like if this was not the case.
I am using Android Gradle 1.1 (along with Android Studio 1.1), and I think this is causing me some issues. I have tried all the solutions I could find - unfortunately, none of them seem to apply for Android Gradle 1.1 - for example:
Removing the sourceSets
from B's build.gradle
and adding (to B's dependencies) the line
testCompile project(':A').sourceSets.test.output
Produces the build error Could not find property 'test' on SourceSet container.
Am I going about this the wrong way? Is there an easier/better way to include test files across modules? I'm pretty new to Gradle/Android Studio, so it's totally possible I'm missing a dead obvious solution.