如何安装/导入AndroidJunitRunner

时间:2015-06-18 14:17:47

标签: android junit android-gradle

按照https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions的说明添加了

androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test:runner:0.3'

到我的gradle构建文件,

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

aar文件可在

中找到
/{sdk_home}/extras/android/m2repository

显然,这并不意味着gradle现在可以找到它们。如何告诉gradle在那里查找文件,或者如何创建依赖项?将aar文件放在我的libs目录中并从那里导入它们不起作用。通常不适用于aar文件。

这是我的gradle构建文件:

repositories {
mavenCentral() // this or jcenter() required for testing-support-lib dependencies
mavenLocal()
}

    apply plugin: 'com.android.application'
apply plugin: 'findbugs'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.loqli.android"
    minSdkVersion 18
    targetSdkVersion 22
    multiDexEnabled = true

    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
}

   sourceSets {
        main {
            java.srcDirs = ['src/main/java']
            resources.srcDirs = ['src/main/res']
        }
        androidTest {
            java.srcDirs = ['src/test/java']
            resources.srcDirs = ['src/test/res']
        }
    }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

dexOptions {
    incremental true
    javaMaxHeapSize "4096M"
}

}

dependencies {

wearApp project(':wear')

compile 'com.android.support:support-v4:+'
compile 'com.google.android.gms:play-services-wearable:+'

compile 'com.android.support:support-annotations:22.2.0'

compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs/roboguice', include: ['*.jar'])

//androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'

androidTestCompile 'com.android.support.test:runner:0.3'
}

编辑:更新的gradle构建文件

0 个答案:

没有答案