Android Test

2015-11-19  本文已影响178人  hello_cc

Unit Test

dependencies {    
        // Unit testing dependencies    
        testCompile 'junit:junit:4.12'    
        // Set this dependency if you want to use Mockito
        testCompile 'org.mockito:mockito-core:1.10.19'    
        // Set this dependency if you want to use Hamcrest matching  
        testCompile 'org.hamcrest:hamcrest-library:1.1'
}
  1. 官方参考文档

Instrumented Unit Tests

defaultConfig {
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
  1. 项目结构(app/src/main/java)
    测试路径(app/src/androidTest/java)
  2. 添加依赖
dependencies {    
        androidTestCompile 'com.android.support:support-annotations:23.0.1'    
        androidTestCompile 'com.android.support.test:runner:0.4.1'   
        androidTestCompile 'com.android.support.test:rules:0.4.1'    
        // Set this dependency if you want to use Hamcrest matching  
        androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
}
  1. 官方参考文档

参考

  1. Android Test官方文档,Github
  2. 测试模版GitHub
  3. Hamcrest,Mockito
上一篇 下一篇

猜你喜欢

热点阅读