Test resources folder with Robolectric and Gradle
I guess your issue is related to an open issue at google. https://code.google.com/p/android/issues/detail?id=136013
There exist also a workaround here an unmodified copy from post #10
import groovy.json.StringEscapeUtilsgradle.projectsEvaluated {def variants = android.applicationVariants.collect()tasks.withType(Test) { task -> try { variants.each { variant -> def buildTypeName = variant.buildType.name.capitalize() def productFlavorNames = variant.productFlavors.collect { it.name.capitalize() } if (productFlavorNames.isEmpty()) { productFlavorNames = [""] } def productFlavorName = productFlavorNames.join('') def flavor = StringUtils.uncapitalize(productFlavorName) def variationName = "${productFlavorName}${buildTypeName}" if (task.name.contains(variationName)) { def variationPath = variant.buildType.name; if (StringUtils.isNotEmpty(productFlavorName)) { variationPath = StringUtils.uncapitalize(productFlavorName) + "/" + variationPath } def copyTestResourcesTask = project.tasks.create("copyTest${variationName}Resources", Copy) copyTestResourcesTask.from("${projectDir}/src/test/resources") copyTestResourcesTask.into("${buildDir}/intermediates/classes/test/${variationPath}") // Makes the test task depend on the copy test resource variation task task.dependsOn(copyTestResourcesTask) variants.remove(variant) throw new Exception("Break") // Breaking the loop } } } catch (Exception e) {} // Just drop the exception}}
and here you can find a working example https://github.com/nenick/android-gradle-template/blob/master/App/build.gradle