Online. Offline. Bottom Line.™ (skip to the content)

Home | About | Jobs | Privacy Policy | Contact | Login or Register


Unit Testing with Android

by

There is one word that is guaranteed to generate excitement in mobile development communities right now - Android.  Google’s venture into the mobile SDK realm was eagerly anticipated, and its release, paired with a development challenge, didn’t disappoint.  Now however, as the freshness wears off and serious development begins to become more commonplace, Android’s first real shortcoming becomes clear.  Unit Testing…

At first glance it looks like unit testing is easy in Android.  Indeed, the SDK includes JUnit, and even extends it into a testing package.  Being the Test Driven Development aficionado that I am, I of course tried the testing package out when I made my first “Hello World” android application.  And that is when I found out that creating the Android UI objects, such as the Bundles and Activities, in a test context is pretty much impossible.  Documentation for using the testing package is non-existent, another un-Google=like characteristic of Android.  Searching through the various development forums tells me that I am not the only one having problems.

All is not lost however.  First, there is always the tried and true method of moving business functionality out of the UI layer and into a seperate service layer, which is easier to test.  And then there are third party libraries than have begun to spring up in development circles.  Positron has emerged as the most popular.  Positron contains a method called startActivity() that allows you to use Android’s libraries to start and initialize the activity in a testing context.  More importantly, it also has documentation that supplies instructions and examples of how to use it.  So until someone out there figures out how to use Android’s internal testing package, I will be using Positron.

Found in • (0) CommentsPermalink http://www.sundog.net/index.php/sunblog/entry/unit-testing-with-android/
Like this post? Subscribe to our RSS feed. RSS icon

© 2008 Sundog, All Rights Reserved xhtml | css | 508 | What's This?