在Android中使用仪器GUI测试仪器、测试、Android、GUI

2023-09-05 08:37:27 作者:只为沵癫狂

我想测试我的Andr​​oid应用程序的用户界面,具有的KeyEvent和pressed按钮等。我读过索姆文档仪表将能够用于此目的。

I want to test my Android applications UI, with keyevents and pressed buttons and so on. I've read som documentation that Instrumentation would be able to use for this purpose.

任何人只要有expericence使用仪器的UI测试?

Anyone with expericence with using Instrumentation for UI testing?

推荐答案

在正式推荐的方式来进行UI测试Android上的仪器,是的。看一看InstrumentationTestRunner.存在着包装的这种功能,这使得它使用较少有点痛苦,其中之一就是 Robotium ,另一种是 Calculon 。

The officially recommended way to perform UI tests on Android is instrumentation, yes. Have a look at InstrumentationTestRunner. There exist wrappers for this sort of functionality which make it a little less painful to use, one of these is Robotium, another is Calculon.

然而,大多数人似乎都同意这些天,谷歌的测试框架是一个失败。这是很酥,很慢,这些API是可怕的,使得测试难以编写和理解。因此,一般人我知道,运行大型测试套件选择 Robolectric ,这需要UI测试远离设备和Dalvik的一个纯旧的JVM。它已经走过了漫长的道路,实际上是非常有用的,这些天。一探究竟。的主要缺点是当然,这将不实际仪器的设备上的应用程序,甚至呈现UI的。这使得在code级断言,所以它不是黑箱测试是正确的选择。

However, most people seem to agree these days that Google's test framework is a fail. It's very flaky, very slow, and the APIs are terrible, making tests difficult to write and understand. Hence, most people I know that run larger test suites opt for Robolectric, which takes UI testing away from the device and Dalvik to a plain old JVM. It has come a long way, and is actually very usable these days. Check it out. The main drawback is of course that it won't actually instrument the app on a device or even render the UI. It makes assertions on code level, so it's not the right choice for black box tests.

另一种方法是黑盒/终端到终端的测试你的应用程序是硒+ NativeDriver 。 NativeDriver是webdriver的API的执行情况,所以你可以对你的Andr​​oid设备上运行Selenium风格测试。

Another way to black box / end-to-end test your app is Selenium + NativeDriver. NativeDriver is an implementation of the WebDriver APIs, so you can run Selenium style tests against your Android devices.

还有一个工具提的是Android的自身的monkeyrunner (未猴子的UI锻炼,这简单地发送随机事件的装置,因此它可以用于压力测试,但不进行功能测试)。 monkeyrunner是一个Python脚本化设备的桥梁,对您可以在顺序发送键击和水龙头来测试您的应用程序。同样,我不建议使用它,虽然,因为它充满了错误和具有非常有限的功能。它可以做其他的事情,虽然,如服用您的应用程序的截图测试。

One more tool to mention is Android's own monkeyrunner (not the Monkey UI exerciser, which simply sends random events to a device, making it useful for stress testing, but not for functional testing). monkeyrunner is a Python scripted device bridge, against which you can send keystrokes and taps in order to instrument your app. Again, I wouldn't recommend using it though, since it's riddled with bugs and has very limited functionality. It can do other things though, such as taking screenshots of your app under test.

 
精彩推荐
图片推荐