Hi,

Missed your response.  This didn't work for me unfortunately.

Interestingly if I mark the test with @UiThreadTest I get the same
deadlock behavior, which makes me wonder whether there is some sort of
JUnit test state being re-used when the test is run in a suite?

As it stands I have a bunch of important test cases that I'm having to
just comment out because they hang when run in the suite (although
they all run and pass when executed individually).

I feel like I've tried everything to get these to work, but clearly
I'm missing something here.

Any other ideas?

Thanks,

Jason.

On Mar 17, 7:59 pm, Streets Of Boston <[email protected]> wrote:
> JUnit test-methods in the instrumentation test-case classes always run in
> another thread than the main UI thread. I run both indiviual test-cases and
> test-suites (that execute lists of test-cases) and test-methods are always
> called in a different thread than the background thread.
>
> I read this in your original question: "*... This method call (internally)
> launches an AsyncTask ...*". I ran into a problem and this may be related to
> your issue:
> You have to *create the first AsyncTask of your (test-)process in the main
> UI thread*. If you don't do this, and the (first) AsyncTask is created in a
> non-UI thread (e.g. during a testXXXX() method), weird stuff can happen. In
> other words: Be sure that the VM loads the AsyncTask *class* in the main UI
> thread. From then on, you can create and execute AsynTasks in any thread.
>
> E.g in your first test's setup or the first testXXXXX() method:
>   ...
>   runTestOnUIThread(new Runnable() {
>     public void run() {
>       new AsyncTask(); // just create one and let it go; doing this makes
> sure that the class loads in the main UI thread.
>     }
>   }
>   ...
>   ... // now you're free to create and execute AsyncTasks (directly or
> through other method calls).
>
> Maybe this problem is related to the one you see.

-- 
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

Reply via email to