Hi all.
I'm working on a fairly complex project that involves many build types and flavours.
Up until now we've been using fairly old versions of Gradle and Android Studio together with a few third party plugins to run Robolectric tests command line and from the IDE (JCAndK, evant).
That all worked fine.
Now we've upgraded to latest AS (1.1), latest Android Gradle (1.1.2) and latest Robolectric (2.4, Gradle plugin 1.0.1).
The plain Java Unit tests works great now in the IDE and command line, but any tests depending on Robolectric are broken for us.
What we have noticed is that the tests *only* run when the following are added to the test configuration VM options,
-Dandroid.manifest="<path>/AndroidManifest.xml" -Dandroid.resources="<path>/res" -Dandroid.package="our.app.com" -Dandroid.assets="<path>/assets"
I don't really understand how and when this gets added to the configuration, but it seems fairly random and most of the time we have to copy and paste it manually into the test config (Edit Configurations for the test). (We run the tests via the IDE "Run", as per convention - nothing strange).
Also, it doesn't run at all command line any more.
It either fails because it can't find our "TestApplication" class that lives in the same package as the real app and overrides various dependencies for test, or because it can't find resources (such as android.content.res.Resources$NotFoundException: unknown resource 2131296463). All of which worked fine before and works fine in the IDE with the above manual hack.
I've tested to bring this down to barebones for the Gradle config for test,
apply plugin: 'org.robolectric'
testCompile 'org.robolectric:robolectric:2.4'
Still the same issues.
Could someone explain how the manifest/resource/package/assets stuff gets setup and what triggers it? What could we be missing in our setup? Is this related to build types and flavors? Plan JUnit tests run fine in all the combos, so seems to be Robolectric specific issue.
On another note - we are extending the RobolectricTestRunner purely to override the Maven repository settings as we're behind a company firewall and have to use their Maven proxies.
In 2.3, we could override 'configureMaven' in the test runner to do this, but this method does not exist anymore in 2.4 and it seems to be hidden behind a few layers of code.
How can we configure the Maven repo Robolectric should fetch from in 2.4?
Thanks in advance