I will be giving a presentation tomorrow on Android Testing strategies for Mobile Monday (MoMo) Lansing. The target audience is a blend of developers, managers, and anyone else interested in mobile. My presentation is publicly available on Google Drive as is my demo source code hosted on bitbucket.
In preparation I had to come up to speed on the basics of the Google Android Testing Framework and the Robolectric Testing Framework. I first learned about Robolectric over lunch at CodeMash 2013 and then got a great demonstration and some setup help from Nathan Dotz at Detroit DevFest 2013.
I am still pretty new to Android and am most comfortable working in the Eclipse IDE so that is how I configured my demo application and tests for my talk. Here are a few notes of my experiences trying to get everything configured properly:
Android Testing Framework
- I purchased a copy of the Android Application Testing Guide by Diego Torres Milano
- I had no trouble setting up an Android Test Project following his instructions, except I had to manually add a Library reference to JUnit 3 which I didn't see mentioned
- I shamelessly borrowed his concept of a TemperatureConverter app to use as my demo
Robolectric
- This was definitely harder to configure, I found the configuration instructions at the Robolectric site to be somewhat confusing
- One thing that threw me off was Maven. Turns out you don't need Maven to use Robolectric, but I spent several hours trying to get is configured on my own following the Maven quick-start instructions and then with help from Nathan Dotz.
- Generally speaking I found the Eclipse quick start instructions to be clear with these notes:
- I could not get the M2Eclipse plugin installed and didn't have time to figure out the problem
- I created my lib folder within Eclipse, not at the command line
- I used robolectric-1.3-20130226.015747-4-jar-with-dependencies.jar
- Will be demonstrating EasyMock as well so also copied in easymock-3.1.jar
- When I tried to run my first Robolectric test (as shown in their documentation), I encountered this error: "WARNING: Unable to find path to Android SDK"
- I resolved this problem from the command line:
$ CD to the folder containing my project root
$ android update project -p {my project name}
Robolectric provides a sample app with tests covering some of the basics. I couldn't open the sample in Eclipse because of my M2Eclipse plugin woes so instead I opened it into IntelliJ IDEA which was a painless process.
No comments:
Post a Comment