In this case, I am testing the activities of my app with
ActivityInstrumentationTestCase2. (I also have tests for the
ContentProvider using ProviderTestCase2.) The two tests that I outlined
earlier are for the data entry activity. I want to verify that the data
entered is inserted into the underlying database. The Activity inserts the
data via `getContentResolver.insert()`. The test case then opens the
database directly to assert that the data is there. How would I use a
MockContentProvider and/or other mock objects to perform this kind of
testing?

On Sun, Feb 23, 2014 at 12:29 PM, Danny D <[email protected]> wrote:

> As I read your reply, I'm confused now about what's being tested.  Are you
> testing the ContentProvider or the Activity?  If testing the Activity, it
> may be better to create a MockContentProvider that's responsible for
> providing back the info.  If testing the ContentProvider, skip the Activity
> and use an Application test case, as you get direct control of when its
> created or destroyed.
>
> Sometimes its hard to do, but the goal in testing is to isolate the
> components and build known conditions around them.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" 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/android-developers?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/oOCF2V8tf90/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>



On Sun, Feb 23, 2014 at 12:29 PM, Danny D <[email protected]> wrote:

> As I read your reply, I'm confused now about what's being tested.  Are you
> testing the ContentProvider or the Activity?  If testing the Activity, it
> may be better to create a MockContentProvider that's responsible for
> providing back the info.  If testing the ContentProvider, skip the Activity
> and use an Application test case, as you get direct control of when its
> created or destroyed.
>
> Sometimes its hard to do, but the goal in testing is to isolate the
> components and build known conditions around them.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" 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/android-developers?hl=en
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/oOCF2V8tf90/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" 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/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to