从Robotium测试用例中的错误线程异常调用 [英] Called from Wrong Thread Exception in Robotium Testcase
问题描述
我正在为具有多个活动的android应用程序使用Robotium
编写Testcase.该应用程序在UI中实现Drawer
.但是,当独奏打开抽屉时,它会给出异常Called From Wrong Thread Exception
.单击ActionBar Home时,抽屉将加载.
I'm writing Testcase using Robotium
for my android app which has multiple activities. The app implements Drawer
in UI. But when solo opens drawer, it gives the exception Called From Wrong Thread Exception
. Drawer loads when ActionBar Home is clicked.
public void test4Drawer()
{
solo1.clickOnActionBarHomeButton();
Boolean actual=solo1.searchText("About");
Boolean expected =true;
assertEquals("Drawer Not Loaded",expected,actual);
}
推荐答案
4.3版的Robotium runOnUiThread
中存在问题,将无济于事.
There is a problem in the 4.3 version of Robotium runOnUiThread
will not help.
相关的错误报告指出它已在Robotium中修复4.3.1版本.
As the associated bug report says it's fixed in Robotium 4.3.1 version.
此处下载.
如果保留runOnUiThread
代码并升级lib,则logcat中将出现更明确的异常:
If you keep the runOnUiThread
code and upgrade the lib, you will have a much more explicit exception in the logcat:
E/AndroidRuntime(32201): java.lang.RuntimeException:
This method can not be called from the main application thread
删除runOnUiThread
,就可以了.
这篇关于从Robotium测试用例中的错误线程异常调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!