美文网首页
Android test 2: Intrumentation t

Android test 2: Intrumentation t

作者: saronic | 来源:发表于2016-10-19 08:23 被阅读32次

version:0.1; Edited on: 2016-10-19; Android stuido:2.2.1

第一个Instrumentation test

Android studio 新建默认项目

添加dependency

添加androidTestCompile

AS 中新建的项目默认没有添加instrumentation dependency,需要自己添加,有两种方式:

  • 方式1:
    打开build.gradle(Module.app),在denpendencies里面添加
dependencies {
    //... ... other dependencies
    androidTestCompile 'com.android.support:support-annotations:24.2.1'
    androidTestCompile 'com.android.support.test:runner:0.5'
}
  • 方式2:
    在App的module setting中,添加App的Library dependency,选择androidTestCompile 'com.android.support:support-annotations:24.2.1' 和 androidTestCompile 'com.android.support.test:runner:0.5',注意scope要选择testcompile

确认gradle的defaultConfig

确认build.gradle(Module.app)的 android->defaultConfig里面有
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

相关文章

网友评论

      本文标题:Android test 2: Intrumentation t

      本文链接:https://www.haomeiwen.com/subject/whtxuttx.html