testBuildType + instrumentTestCompile + Android Studio incompatible

835 views
Skip to first unread message

Tobias Bieniek

unread,
Nov 27, 2013, 4:33:20 AM11/27/13
to adt...@googlegroups.com
I'm having a bit of a problem with the combination of the three components mentioned above.

I have a simple app and would like to test it, so I added a MainActivityTest class to src/instrumentTest/java/<package-name>.test. That works pretty well and I've used the Robotium library to make testing a bit easier here. I've added the dependency on Robotium to the build.gradle file with an instrumentTestCompile directive in the dependencies block.

Due to various reasons I would want to use the testBuildType option. I've created a new buildType called "testWrapper" by using "testWrapper.initWith(buildTypes.debug)" and set the packageNameSuffix to ".test" so that I can install the app for testing separately on the device. After that I've set the testBuildType to "testWrapper".

At that point Android Studio suddenly fails to import the Robotium library. When I run the connectedInstrumentTest task it works without problem, but Android Studio apparently fails to understand the dependency logic.

This looks like a bug in Android Studio to me, but maybe I'm doing something wrong. If anyone has an idea, I'd love to hear it!

In the meantime I've discovered how to make Android Studio find the imports again: Go to File -> Project Structure and if you see any unused dependency errors there, fix them by adding the dependencies to the project manually.

Even though the above solutions kinda works, I don't think this is the desired behavior and I hope it will get fixed soon.

Xavier Ducrohet

unread,
Nov 27, 2013, 12:41:55 PM11/27/13
to adt...@googlegroups.com
This sounds broken.

Side Note: you know you could do the packageNameSuffix on the debug build type. right?

I'll look into it but if you could file a bug that would be best. thanks.


--
You received this message because you are subscribed to the Google Groups "adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adt-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Xavier Ducrohet
Android SDK Tech Lead
Google Inc.
http://developer.android.com | http://tools.android.com

Please do not send me questions directly. Thanks!

Tobias Bieniek

unread,
Nov 28, 2013, 9:30:54 AM11/28/13
to adt...@googlegroups.com

Side Note: you know you could do the packageNameSuffix on the debug build type. right?

Yes, I know. The reason for not doing it is that the app is connecting to an API server that is mocked during testing and the URL to the server is changed to localhost by using an additional strings.xml for the testWrapper build type.

I'll look into it but if you could file a bug that would be best. thanks.

Where can I do that?

Jake Wharton

unread,
Nov 28, 2013, 4:40:19 PM11/28/13
to adt...@googlegroups.com

b.android.com

--

Tobias Bieniek

unread,
Nov 28, 2013, 4:42:00 PM11/28/13
to adt...@googlegroups.com
alright, thanks. thought there was a specific tracker for Android
Studio or something like that...

Tobias Bieniek

unread,
Nov 28, 2013, 4:46:34 PM11/28/13
to adt...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages