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
}
}
}
网友评论