Old habits die hard

by Stephen Ng and Noel Yap

Old habits die hard. Particularly when it comes to testing--once you get used to working in a project blanketed with lots of fast-running unit tests, it's hard to go back.

So when some of us at Google learned that we weren't able to use our favorite mocking libraries when writing for our favorite mobile platform (Android, naturally), we decided to do something about it.

As many of you already know (since you read this blog), mocking combined with dependency injection is a valuable technique for helping you write small, focused unit tests. And those tests in turn can help you structure your code so that it's loosely coupled, making it more readable and maintainable.

With a bit of setup, this can be done in Android, too. We've put together a tutorial describing our approach. It's the first installment in what we hope will be a series of articles on android app development and testing, from the perspective of Googlers who are not actually on the Android team. We'd love to hear whether you find it useful.

Permalink | Links to this post |
The comments you read here belong only to the person who posted them. We do, however, reserve the right to remove off-topic comments.

3 comments:

Iker said...

This Ganesh guy is posting the same useless comment on all the blog entries (check http://googletesting.blogspot.com/2009/07/why-are-we-embarrassed-to-admit-that-we.html) to get links to his blog.
What a spammer!

Patrick Copeland said...

Thanks. Agree that duplicate comments aren't useful. I removed it.

stanb said...

This is a comment for your "An Experimental Approach to Writing Unit Tests" article. To the point: it's great. Keep posting anything you learn in this field. I find not a lot information about testing Android apps.
So far, I have been using Positron aka Autoandroid to do testing (this framework allows only for functional testing), which works relatively well. However, these tests are slow and the project is almost abandoned by its developer.
Then, recently, in Android 1.5 I have found that the support for Android native, unit and functional testing, has improved, and I was going to switch to it.
But then, since I have found your article (An Experimental Approach to Writing Unit Tests), I'm thinking of following the approach you suggest in it.
Any farther thoughts on this approach? Are you doing TDD, even if with CALTAL for your Android development? I'm definitely interested to here any comments from you as well as any other developers. I, on my side, provide some more info on this topic on my blog at http://sberka.blogspot.com.