问题描述
我有一个问题设立Robotium测试,无随机假posivities特拉维斯上运行。
每对夫妇的构建,我得到
pl.mg6.agrtt.TestActivityTests> testCanEnterTextAnd pressButton [测试(AVD) - 4.4.2]失败
junit.framework.AssertionFailedError:EditText上没有找到!
在com.robotium.solo.Waiter.waitForAndGetView(Waiter.java:540)
在我所有的测试。
我已经创建的显示问题。结果
您可能会看到它是如何建立。注构建#7 modyfing无关的文件后失败。
我怀疑这是由仿真器引起的被锁定或其sceeen变暗。我可以熄灭后,再连接设备的屏幕上,然后运行重现本地机器上的这个问题。
./ gradlew connectedAndroidTest
modyfing测试后我得到一个不同的错误信息,这是有点更多的信息,所以我将它添加,以防万一有人试图找到一个解决办法:
pl.mg6.agrtt.TestActivityTests> testCanFindViewsEnterTextAnd pressButton [测试(AVD) - 4.4.2]失败
junit.framework.AssertionFailedError:点击(160.0,264.0)无法完成! (java.lang.SecurityException异常:注射到另一个应用程序需要INJECT_EVENTS许可)
在com.robotium.solo.Clicker.clickOnScreen(Clicker.java:106)
虽然这个问题的根本原因仍然是未知的我,经过一番考察,并与Robotium的作者的我可以证实我起初怀疑是仿真器确实锁定本身。
我现在使用一种解决方法是这样的code将在设置
方法:
getInstrumentation()。runOnMainSync(新的Runnable(){
@覆盖
公共无效的run(){
。getActivity()getWindow()addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
});
I have a problem setting up Robotium tests to run on Travis without random false posivities.
Every couple of builds I get
pl.mg6.agrtt.TestActivityTests > testCanEnterTextAndPressButton[test(AVD) - 4.4.2] FAILED
junit.framework.AssertionFailedError: EditText is not found!
at com.robotium.solo.Waiter.waitForAndGetView(Waiter.java:540)
on all my tests.
I have created a simple project on GitHub to show the issue.
You may see how it builds on Travis. Note build #7 failed after modyfing unrelated file.
I'm suspecting this to be caused by emulator being locked or its sceeen dimmed. I could reproduce this issue on local machine by turning connected device's screen off and then running
./gradlew connectedAndroidTest
After modyfing tests I got a different error message, which is somewhat more informative, so I'm adding it just in case someone tries to find a solution:
pl.mg6.agrtt.TestActivityTests > testCanFindViewsEnterTextAndPressButton[test(AVD) - 4.4.2] FAILED
junit.framework.AssertionFailedError: Click at (160.0, 264.0) can not be completed! (java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission)
at com.robotium.solo.Clicker.clickOnScreen(Clicker.java:106)
While the root cause of this problem is still unknown to me, after some investigation and with a help from Robotium's author Renas Reda I could confirm what I initially suspected that emulator indeed locks itself.
A workaround I'm using now is this code put in setUp
method:
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
});
这篇关于误报:junit.framework.AssertionFailedError:EditText上未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!