Most of our Android projects are using great-expectations, which brings Jasmine-style test assertions. Thanks, Xian, for writing this!
Robolectric Enhancements — Stay Tuned
We have a bunch of Robolectric enhancements, including the ability to wire up
BroadcastReceivers by just declaring them in
AndroidManifest.xml. We’ll have to put some pull-requests together soon.
Roboguice uses Robolectric!
We use Roboguice on most of our Android projects for dependency injection. We discovered that Roboguice is using Robolectric for unit testing. Awesome!
One of our projects just started implementing the Android Cloud to Device Messaging (C2DM) framework. We’ll keep you posted as we progress through the many pieces of this implementation. Various resources include:
- Official Google code page: Google Projects for Android: C2DM
- Sign up for the service — you’ll need a Google account, like GMail or a hosted Google account.
- There is no official Android client library for handling these messages. There is a de-facto standard set of classes, as used in JumpNote and Google Chrome to Phone Extension. Most blog and forum posts say something like “Download those classes and tweak as needed.”
- Wei Huang from Google posted an article about implementing C2DM.
- Now for the Ruby part — wait, Ruby? Yes, there is a big server-side component to C2DM. Your message-pushing server must not obtain an authorization token from Google to communicate with the service, but also keep track of the authorization tokens from each device that needs to receive push notifications. We are implementing a server-side API for our devices to register their C2DM tokens. Also, the awesome folks at GroupMe have open sourced a c2dm gem for Ruby servers to both authorize with Google and post notifications.
Un-shadowed Method Warnings!
In response to yesterday’s question about Un-shadowed Method Warnings, Pivot Tyler points out that you can turn these on by calling
On two workstations every unit test was failing with the following error:
// …many levels of stack trace, finally:
Caused by: com.xtremelabs.robolectric.bytecode.IgnorableClassNotFoundException: msg because of javassist.NotFoundException: android.content.DialogInterface$OnShowListener
Cause: there was an old
tmp/cached-robolectric-classes.jar that was causing these errors and our tests ran successfully after deleting it. That’s two answers from Pivot Tyler!
Don’t DDOS Yourself With Your Own App
The Bump Android team wrote an article about a good idea gone wrong. Moral of the story: not all devices behave the same, and this might cripple your servers rather than the devices.
Robolectric Google Group
Join it, contribute, and learn about unit testing your Android apps.
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):
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…
What options exist for mobile application development?
The general consensus seems to be that many of these frameworks work fine for simple applications, but quickly run into walls, bugs, and fails once things are less than straightforward. If you’re writing a simple application, it probably falls in the mobile web application category and then all you need is a web view. YMMV, but know what you want your application to do before making a choice. Most likely, you have to write a native application for each platform.
- jQuery 1.4.4 Released Read the blog entry for details; if you’re having issues, they might be solved in this release.
There is meeting tonight at 7pm in San Francisco about using MongoDB for mobile backend servers. Will Shulman from MongoLab will be giving the talk. They will also be offering food and prizes to attendees.
More details can be found at:
Next Tuesday, July 14, at 10pm PST, Chris Sepulveda from Pivotal Labs will be broadcasting an O’Reilly WebCast on automated unit testing with the Palm Mojo SDK. Developer testing is at the heart of Pivotal Labs’s development practices, and we’re excited to be involved in bringing testing to Mojo development. The WebCast will cover the following:
- Introduce BDD & Jasmine
- Installing Jasmine & add related code to the app to support BDD
- Discuss how to write a failing test first, then add functionality to make a test pass
- Develop a simple webOS application test first, with the Mojo SDK
There’s more information about the WebCast on webOSHelp.net.
Date: Tuesday, July 14th at 10 am PT
Duration: Approximately 60 minutes
To register: http://oreilly.com/go/palmmojo