I have recently started testing for my android application using Instrumentation framework. I have an Activity A which calls out an AsyncTask in its onCreate() method.
So the problem is, all of my test-cases executes 开发者_C百科one after the other and does not wait for AsyncTask to get completed. So how can I implement the thing that waits until the thread has been finish and then continue with other test cases?
Thanks
Depends a lot on how you're doing things. You could set the test thread waiting (using wait()
or a CountDownLatch
) and notify it when the AsyncTask finishes.. to do that simply call a protected method within the Activity after the AsyncTask is finished and override that method within your test case to notify the test thread.
精彩评论