Here's an alternative way to meet the desire expressed by the OP to
find a way to run unit tests in an IDE like Eclipse using judicious
design instead of dependency injection...

In most cases it will possible to break down the application into some
sort of MVC structure. Usually the model and controller won't require
tight platform integration. Actions will include sending and receiving
messages, caching some data, managing some state, posting events to
view components, reading contacts data, reading a file etc. It will
usually be possible to write an application core with platform-
agnostic J2SE using some sensible platform abstraction interfaces of
the functionality required by the application. This has a number
advantages:
   * It avoids the need to abstract every aspect of a platform or use
a full-blown dependency framework
   * The core application can tested in detail using standard Junit
etc with the help of a mock/spy framework, such as Jmock or EasyMock,
to deal with the small set of platform abstraction interfaces. This
means standard IDE test runners can be used.
   * A standard J2SE core can be reused in other scenarios e.g. a J2ME
client or a J2SE client for server load-testing
   * Platform abstraction interfaces and implementations can be reused
in multiple applications

The view part is clearly tightly coupled to activities, intents, and
the Android UI framework. My preference is to write integration tests
using the Activity instrumentation framework. These tests are by no
means exhaustive. They are integration tests that ensure the Activity
starts ok and key user-driven behaviours work at a high level. For
example, check clicking a button drives a transition to a new
Activity. The J2SE tests are there to check the detailed behaviour.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to