1

最近我开始用集成测试覆盖我的项目,其中 mockito 提供演示者实例来验证我的视图是否在其事件期间正确调用演示者方法。

问题出在具有不可见ProgressBarRecyclerView. 该屏幕的演示者一直在为此加载数据RecyclerView并控制ProgressBar. 当我用 mock(使用 Mockito)替换它时,它会导致相应的测试在一段时间后完全陷入错误:

Could not launch intent Intent { act=android.intent.action.MAIN flg=0x14000000 
cmp=com.example.kinopoisk/com.example.mvp.view.activity.MainActivity } within 45 seconds. 
Perhaps the main thread has not gone idle within a reasonable amount of time? 
There could be an animation or something constantly repainting the screen. 
Or the activity is doing network calls on creation? See the threaddump logs. 
For your reference the last time the event queue was idle before your activity launch request 
was 1476191336691 and now the last time the queue went idle was: 1476191336691. 
If these numbers are the same your activity might be hogging the event queue

但活动已成功运行,并且可供所有用户事件(如点击等)访问。

你怎么看,是什么导致了问题?

这只是社区知识库的问题,我自己找到了答案

4

1 回答 1

0

解释在那一行错误代码中:可能有动画或不断重绘屏幕的东西。

当我用mockito 替换presenter 时,它也停止控制进度条。它的初始状态是View.VISIBLE,所以这是导致测试无法连接的原因。

解决方案只是将初始状态设置为ProgressBarto View.GONE,但发现这对我来说有点头疼。

于 2016-10-11T13:35:08.077 回答