Bind always returns true if the intent finds the service, but actual start
is delayed (if necessary). The return value is not an indication of current
state, as you've already discovered.

One possibility is to make a static in the service for testing only, set it
in onCreate and cleared in onDestroy.

--
Kostya Vasilyev -- http://kmansoft.wordpress.com
18.12.2010 17:03 пользователь "Ian" <ian.fawcett.hun...@gmail.com> написал:
> I have a scenario...
>
> 1. User presses button.
> 2. Dialog opens; user presses 'OK'
> 3. Activity starts a service.
>
> I wish to provide a JUnit test for (3).
>
> Can anybody please advise me how to do this.
>
> I've tried using ActivityInstrumentationTestCase2 for my MyActivity,
> testing that the service is not running, using Robotium to drive GUI,
> and then testing service is running.
>
> The initial test that the service is NOT running (using bind()) always
> passes true, even though I'm using 0 as last param. which I
> *understand* will not do AUTO_CREATE.
>
> Any ideas/info appreciated.
>
> [I understand there is ServiceTestCase for testing the service, but I
> only want to test that the Activity starts the service correctly].
>
> Many Thanks
> Ian Hunter
>
> --
> 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<android-developers%2bunsubscr...@googlegroups.com>
> 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 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