We’re trying an experiment: since we currently have several Android projects at Pivotal Labs, and Android development and testing is hard, we are going to post to the blog the tips, tricks, gotchas, and conundrums we find.
Emulator and Orientation
Android will destroy and recreate activities upon screen orientation change. One way to prevent this is to set
android:configChanges="orientation" in your
AndroidManifest.xml (article here):
<activity android:name=".activities.MyActivity" android:configChanges="orientation"/>
This prevents android from calling
onCreate() on a device, but not within the emulator; annoyingly, the Activity is still recreated within the emulator.
Un-shadowed Method Warnings?
Once again we spent about 15 minutes debugging a failing unit test only to find that there was no Robolectric implementation/shadow for one of the Android methods under test (
ArrayAdapter#insert in our case). I would be nice to have a “warning mode” where Robolectric would log warning for all un-shadowed methods. I wish we knew the guys who wrote Robolectric…
About the AuthorMore Content by Joe Moore