android-studio-unit-test-plugin
android-studio-unit-test-plugin copied to clipboard
Resource files not picked up in test variant
Robolectric allows to place its configuration in a special config file org.robolectric.Config.properties
that usually resides in src/test/resources
. While this is correctly picked up when I execute ./gradlew test
on command line, it isn't when I run the test through Android Studio.
Right now, test resources are not supported at all.
Hi, is there any progress to that issue? I'd also need that feature :-) Matthias
@klassm No work so far. I do have a rough idea of what needs to be done.
Well this would be absolutely a wonderful feature :-)
I did make a bit of progress on this. Resource directories are now marked correctly if you are on the latest version of the gradle plugin. However, they are still not added to the classpath. I think its because the build dir is set up differently than a standard java project due to flavors. I can't seem to find a way to modify the classpath of the test runner to account for this. If you are really dieing for this feature, you could probably hack something together with a task that copies the resources into test-classes.
@tommyd3mdi @klassm This will probably never be implemented because it requires recreating the entire classpath for the junit test runner. Intellij 14 has a new gradle test runner that solves this (and several other problems). So your best bet is to use that, or wait until the changes get rolled into Android Studio.
Ok great. Thanks!
Reopening so others can find it.
Actually (AS 1.0-RC) the main resource folder it's find correctly, but their flavor counterpart not
You can fix this by copying the test resources via build.gradle:
//Copy test resources to classpath folder. See https://code.google.com/p/android/issues/detail?id=74443
tasks.findByName("assembleDebug").dependsOn("copyTestResources")
task copyTestResources(type: Copy) {
from "${projectDir}/src/testDebug/resources"
into "${buildDir}/test-classes/debug/resources"
}