tags:

views:

27

answers:

1

Hello, I have a question, I am relatively new to Android and threads etc...anyways, hoping there is help for me.

I am writing unit tests (AndroidTestCase). The application under test uses some background services to communicate over the web the get information.

To recieve notification of events I am interested in, (like when content has been delivered etc), I register a listener that exposes various methods. In these listener interface methods, I assert certain things to help me validate i am getting appropriate responses.

My problem is that the test methods are finishing prior to the callback occuring and I do not know how to tell the method to "wait" for the callback to happen.

Any insight would be greatly appreciated.

Thanks Sean

A: 

You should use AsyncTask for all background thread work... it makes life oh-so-much easier.

Then in your onPostExecute() implementation, which will run on the UI thread once the worker thread is completed, you can run your test methods.

Reuben Scratton
Thanks Rueben, I'll look into it and get back...
Stiley