Android Studio Instrumentation测试构建版本 [英] Android Studio Instrumentation testing build variant

查看:148
本文介绍了Android Studio Instrumentation测试构建版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在尝试使用自定义构建变体模拟来编写检测测试.在这个构建变体中,我模拟了我的类和服务器.当我自己尝试使用模拟构建时,它可以正常工作,但是我似乎无法使用模拟构建进行测试.这是我在Android Studio中的配置.

So I am trying to write instrumentation tests using a custom build variant, mock. In this build variant I mocked up my classes and server. When I try using the mock build myself it works fine, but I can't seem to use my mock build for testing. Here's what my configuration looks like inside Android Studio.

在运行测试时遇到了一些问题,因此我尝试卸载我的应用程序的所有版本(除模拟版本外),并且不断出现此错误:

I had some issues getting my tests to run so I tried to uninstall all versions of my app except my mock version and I keep getting this error:

测试运行已开始测试运行失败:无法找到检测目标包:com.teamtreehouse.review.debug

Test running startedTest running failed: Unable to find instrumentation target package: com.teamtreehouse.review.debug

但是,当我尝试针对调试构建变体运行测试时,它运行良好.它会安装我的调试版本,然后继续运行测试.

However when I try to run my tests against the debug build variant it works fine. It installs my debug version then proceeds to run the tests.

推荐答案

可以对其他构建变体进行测试;但只有一个.默认为调试.

You can do testing on a different build variant; but only on one. The default is debug.

查看此: https://developer.android.com/studio/build/gradle-tips#change-the-test-build-type

当前仅测试一种构建类型.默认情况下是调试 构建类型,但是可以使用以下方式重新配置:

Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:

android {
    ...
    testBuildType "staging"
}

这篇关于Android Studio Instrumentation测试构建版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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