The problem here is that your Service is started with instrumentation. Anything else that starts up is outside the control of the instrumentation. Though I'm not certain of this, I would expect that you'd get the behavior you see. The second component that starts up is not aware of the first Service instance, which is running in a special "part" of Android. For this reason, the Service is re-started.
In general, you can't rely on using the unit testing framework to do functional tests. It's not designed for that, and in most cases it won't work as you expect it to. The Android test case classes are there to make JUnit-style unit testing possible within the Android environment. They're not a substitute for functional/framework-level testing. If you want a higher-level testing framework, you may want to look at monkeyrunner. This tool is available in the Android Open Source project. Joe On Nov 17, 6:55 am, Faboom <[email protected]> wrote: > Hello, > i know it should be impossible, but maybe under tests its a different > thing. > The test is a functional test, which involves other system components > such as BroadcastReceiver and Activities. It is SDK 1.6. > > I start the service within a ServiceTestCase without injecting custom > context or application. > > During the test another android component starts (as intended) the > same service again with Context.startService(Intent bar). > Instead of calling onStart in the existing Service, a new Instance of > the Service is created. > The logs report via "this", that two different service objects are > running in parallel. > > How can I test the behavior of a service that is started multiple > times with different intents? -- 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

