I have 2 modules: A and B.
-A is a standalone module. His tests just work just fine. -B is the dependent module. His tests require a specific file in the test folder (one test file in B extends one of A)
Here is what I consider relevant parts of B 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' }
Although this technically works for what I need, it has an unpleasant side effect: whenever I run unit tests, they also run all of the B tests. I would really like it if it werenโt.
I am using Android Gradle 1.1 (along with Android Studio 1.1), and I think this is causing me some problems. I tried all the solutions I could find - unfortunately, none of them seem to work for Android Gradle 1.1 - for example:
Removing sourceSets from B build.gradle and adding (to B dependencies) a string
testCompile project(':A').sourceSets.test.output
Could not find property 'test' on SourceSet container. build error. Could not find property 'test' on SourceSet container.
Am I really wrong? Is there an easier / better way to include test files through modules? I am new to Gradle / Android Studio, so it is possible that I am missing a dead, obvious solution.
android android-studio android-gradle gradle
Zambezi
source share