美文网首页
单元测试(1)-Gradle配置

单元测试(1)-Gradle配置

作者: lisx_ | 来源:发表于2020-03-23 16:13 被阅读0次

以下是全部的单元测试配置, 包含junit、espresso和uiautomator三个部分。
下面通过注释一一区分和介绍。

defaultConfig {
         // junit 引入单元测试线程
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true  //junit 开启超过65536 个方法数后不再报错
    }


// junit  打开覆盖率统计开关,task里会多出一个createDebugCoverageReport任务,
//直接执行,所有方法都成功后可生成覆盖率报告
    android {
        buildTypes {
            debug {
                 testCoverageEnabled = true
            }
        }
    }

dependencies {
    //noinspection GradleCompatible
// junit
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test:rules:1.0.2'
// espresso
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
//uiautomator
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
}

相关文章

网友评论

      本文标题:单元测试(1)-Gradle配置

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