Testing ViewPager (and CursorLoader) with Robolectric

后端 未结 1 1009
无人共我
无人共我 2021-01-31 06:57

Does anyone know how to test the following setup using Robolectric?

Fragment containing a ViewPager, data loaded with a CursorLoader.

With the code below, the Cu

相关标签:
1条回答
  • 2021-01-31 07:26

    I'm not certain, but I would wager that the internal code is trying to use an AsyncTask to invoke the cursor loader's loadInBackground() method. You might be seeing a deadlock because the AsyncTask tries to invoke onPostExecute(). That call will try to run in your main UI thread, which happens to be the thread of your test routine. That can never happen because you are stuck in a wait with your test routine on the call stack.

    Try moving your mocking up to a higher level so that nothing really happens in the background from the test. google `AsyncTask unit test android deadlock' to see examples where other people ran into similar problems.

    0 讨论(0)
提交回复
热议问题