开发者

Android - Unit testing using Instrumentation Framework

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜