Call waitForMonitorWithTimeout() from a @UiThreadTest

前端 未结 1 1742
独厮守ぢ
独厮守ぢ 2021-01-23 23:51

To illustrate my latest problem with writing JUnit tests for my Android app, I wrote a simple example with two activities, StartActivityForResult and ChildAct

相关标签:
1条回答
  • 2021-01-24 00:48

    As illustrated in an answer to one of my related questions, the problem is that I am calling waitForMonitorWithTimeout() on the UI Thread. After realizing this, it certainly makes complete sense because waitForMonitorWithTimeout() waits for the UI thread to complete some action (namely displaying an Activity's UI). However, by calling it on the UI thread, I am delaying that action from occuring.

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