Android测试(一)--介绍一下

我今天非常认真专注的搜了一下Android测试。
然后很认真的看了几遍,终于让我明白我是看不懂的。
我只看到了这堆东西,JUnit,Mockito,Instrumentation,Espresso,UI Automator......
所以我懵懵懂懂的弄了个图,看图说话:

Android测试(一)--介绍一下_第1张图片
那堆东西

还是看不懂?不关我事,我看懂就可以了。

Android Studio上应用

目前使用Android Studio2.1.1
来看一个官方的图:

Android测试(一)--介绍一下_第2张图片

图片下面有段小字,(1)是用来仪器测试的,(2)是用来JVM单元测试的

Gradle 上面的配置
(1)仪器测试

这里还分单APP测试和多APP测试。
单APP测试,只测试自己的应用内的交互,测试代码写在同一个项目下即可;
多APP测试,自己的APP与其他APP间的交互,比如你分享一张图片到微信上面,想验证微信朋友圈是否成功(这个不就可以写个简单的游戏外挂了),则可以通过该方式,代码要新建一个项目。

单个APP

第一步:

dependencies {
androidTestCompile 'com.android.support:support-annotations:24.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
// Optional -- Hamcrest library
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
// Optional -- UI testing with Espresso
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
}

第二步:

android {
defaultConfig {
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}
多个APP
dependencies {
// Optional -- UI testing with UI Automator
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
}
(2)JVM单元测试
dependencies {
    // Required -- JUnit 4 framework
    testCompile 'junit:junit:4.12'
    // Optional -- Mockito framework
    testCompile 'org.mockito:mockito-core:2.+'
}

下一篇:
Android测试(二)--单元测试

完整教程:
google测试应用教程

你可能感兴趣的:(Android测试(一)--介绍一下)