标签:
// Dependencies for local unit tests
testCompile ‘junit:junit:‘ + rootProject.ext.junitVersion
testCompile ‘org.mockito:mockito-all:‘ + rootProject.ext.mockitoVersion
testCompile ‘org.hamcrest:hamcrest-all:‘ + rootProject.ext.hamcrestVersion
// Android Testing Support Library‘s runner and rules
androidTestCompile ‘com.android.support.test:runner:‘ + rootProject.ext.runnerVersion
androidTestCompile ‘com.android.support.test:rules:‘ + rootProject.ext.rulesVersion
defaultConfig {
testInstrumentationRunner ‘android.support.test.runner.AndroidJUnitRunner‘
}
sourceSets{
main{
java.srcDirs = [‘src‘]
}
androidTest{
java.srcDirs = [‘androidTest/src‘]
}
test{
java.srcDirs = [‘test/src‘]
}
}
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
System.out.println("123");
}
}
public class AndroidRuntimeCodeTest extends AndroidTestCase {
public void testHello() throws Exception {
System.out.println("testHello");
}
}
<uses-library android:name="android.test.runner" />
configurations.all {
resolutionStrategy {
androidTestCompile ‘com.android.support.test:runner:0.4.1‘
androidTestCompile ‘com.android.support.test:rules:0.4.1‘
forcedModules = [‘com.android.support:support-annotations:23.0.1‘]
}
}
在Android Studio进行“简单配置”单元测试(Android Junit)
标签:
原文地址:http://www.cnblogs.com/shortboy/p/5634006.html