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

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

那堆东西

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

Android Studio上应用

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

图片下面有段小字,(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测试应用教程

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 180,480评论 25赞 708
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,964评论 2赞 45
  • 标签(空格分隔): Android 单元测试的好处:Martin Fowler在《重构》里面还解释了为什么单元测试...
    背影杀手不太冷阅读 6,105评论 3赞 25
  • 梦里花影淡,倩人靥浮柔。 醒来帘遮雾,风野更思愁。 适踏西园路,犹忆昨日游。 高楼明月夜,难掩双泪流。
    d03e056874dc阅读 137评论 0赞 0
  • 译文参考自《隐藏的论语》。 解读只是个人暂时的浅见。 这一篇主要讲对命与仁的追求和实践。何为天命?何为本性? 9....
    吾宗老孙子阅读 428评论 0赞 0

友情链接更多精彩内容