美文网首页Android TDD
Android安卓单元测试常用框架引入

Android安卓单元测试常用框架引入

作者: yiyihome | 来源:发表于2017-11-10 09:48 被阅读6次

1 Junit 的引入

APP的 build.gradle中加入

testCompile 'junit:junit:4.12'

我们在使用Android Studio 创建新工程的时候,AS已经默认加上这行了.

2 Mockito 的引入

官网 http://site.mockito.org

引入方式

repositories {  jcenter()  }

dependencies { testCompile"org.mockito:mockito-core:2.+" }

3 Dagger2

官网地址 https://github.com/google/dagger

//Add Dagger dependencies

dependencies { 

 compile 'com.google.dagger:dagger:2.x'

annotationProcessor 'com.google.dagger:dagger-compiler:2.x'

}

4 Robolectric 引入

官网 http://robolectric.org/getting-started/

引入方式

testImplementation "org.robolectric:robolectric:3.5.1" 

android {

    testOptions{

        unitTests{

            includeAndroidResources=true

        }

       }

}

相关文章

网友评论

    本文标题:Android安卓单元测试常用框架引入

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