android - 从 Android Studio (v0.8) 运行 UiAutomator API

标签 android unit-testing android-studio android-uiautomator

当我处理测试时 - 我在特殊模块中添加类并运行测试配置。类扩展(例如)TestCase 并且运行良好。

但是当我扩展 UiAutomatorTestCase - 我得到错误

java.lang.RuntimeException: Stub!
    at com.android.uiautomator.testrunner.UiAutomatorTestCase.<init>  (UiAutomatorTestCase.java:5) ...

我的简单类:

import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class AutoTest extends UiAutomatorTestCase {
    public void testSome() throws UiObjectNotFoundException {
        getUiDevice().pressHome();
    }
}

如何在Android Studio IDE中运行?

最佳答案

好吧,如果您有兴趣再试一次....我能够在 Android Studio 中使用以下 [Github 项目] ( https://github.com/wiliamsouza/bluetooth ) 启动 UIAutomator 项目

  1. 在本地克隆项目。
  2. 编辑 gradle.properties 文件以指向您的 sdk、目标和构建工具
  3. 导入 Android Studio,如果出现提示,请务必选择 Gradle。

随附的 [博文] ( http://wiliamsouza.github.io/#/2013/10/30/android-uiautomator-gradle-build-system ) 有更多详细信息。

我用自己的测试用例进行了修改并且运行良好。

关于android - 从 Android Studio (v0.8) 运行 UiAutomator API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25217199/

相关文章:

java - 呈现网页时 onPageFinished 未正确触发

c++ - googletest:是否可以选择单个测试夹具/案例?

java - 为什么 Reflections.getFieldsAnnotatedWith() 不返回任何字段?

android - 从 Parse 向我的应用程序发送推送时未收到 deviceToken

java - BackgroundColorSpan隐藏文本选择颜色android

android - 从 fragment 类访问 UI 元素

java - 将属性设置为模拟对象 jmock

android - Gradle 脱糖失败,层次结构不完整

android - 使用 Intent.ACTION_SENDTO 时在哪里指定电话号码?

android - 为什么我在 Eclipse 中调试时看不到局部变量?