Android的仪器测试案例 - getinstrumentation()返回null [英] android instrumentation test case - getinstrumentation() returning null

查看:1268
本文介绍了Android的仪器测试案例 - getinstrumentation()返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图做一个测试案例延长intstrumentationtestcase,每当我打电话getinstrumentation()返回仪表的空实例,而不是一个规范的,任何渲染我想这样做没用的自动化。我在清单设置以及即使我只测试自动化上相同的应用程序这种情况下是要上运行的权限...任何想法?

I've been trying to make a test case extending intstrumentationtestcase, and whenever I call getinstrumentation() it returns a null instance of Instrumentation instead of an Instrumentation, rendering any of the automation I'm wanting to do useless. I have the permission set in the manifest as well even though I'm only testing the automation on the same app this case is going to run on...any ideas?

推荐答案

您需要通过调用编程注入仪表 injectInstrumentation(InstrumentationRegistry.getInstrumentation()); 使用 InstrumentationRegistry 从Android官方测试支持-lib目录下:0.1

You need inject the instrumentation programmatically by calling injectInstrumentation(InstrumentationRegistry.getInstrumentation()); using InstrumentationRegistry from the official Android testing-support-lib:0.1

这篇关于Android的仪器测试案例 - getinstrumentation()返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆