On Thu, Nov 4, 2010 at 4:53 AM, jazam <[email protected]> wrote:
> I've been trying to right test code for my app. I've read and re-read
> the android documentation a number of times. I can't work out how to
> test service or content providers. Is there any example source code
> anywhere, I can have a look?

It is a bit tricky, because all of the unit test stuff in android is
intended to run on an emulator or on a real device.  The SDK even has
a custom version of the JUnit jars to try to enforce this.  This is
great... if you want to test something on the device.

If you want to do honest-to-goodness unit testing of a single, non-ui
class, then you almost need to set up a non-android project to host
it.  In fact, you may want to isolate a lot of your non-UI classes in
an external project, with all the tests done as normal, then import
those classes into your main Android project.

Looking back at this, when I say non-UI, I mean non-Android.  All of
your code without direct Android dependencies can be tested in this
way.

Pat.

-- 
Defy mediocrity.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to