Android test 2: Intrumentation test

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

第一個(gè)Instrumentation test

Android studio 新建默認(rèn)項(xiàng)目

添加dependency

添加androidTestCompile

AS 中新建的項(xiàng)目默認(rèn)沒有添加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

確認(rèn)gradle的defaultConfig

確認(rèn)build.gradle(Module.app)的 android->defaultConfig里面有
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容