Robospock和gradle构建变体?

时间:2014-05-19 18:07:41

标签: android unit-testing robospock

我正在使用Robospock进行单元测试并使用gradle进行模拟。这很好用,直到我添加了gradle构建变体。

我的android build.gradle文件:

apply plugin: 'android-library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 19
        versionCode 1
        versionName "0.0.1"
    }


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }


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

    productFlavors {
        uat {
            packageName "com.acme.dev"
        }

        stage {
            packageName "com.acme.staging"
        }

        prod {
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.mcxiaoke.volley:library:1.0.4'
}

我的robospock build.gradle文件:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.8.+'
        classpath 'org.robospock:robospock-plugin:0.4.0'
    }
}

repositories {
    mavenCentral()
}

apply plugin: 'groovy'

dependencies {
    compile "org.codehaus.groovy:groovy-all:1.8.6"
    compile 'org.robospock:robospock:0.4.4'
    compile 'cglib:cglib-nodep:2.2'
    compile 'org.objenesis:objenesis:1.3'
}


project.ext {
    robospock = ":Mothership" // project to test
}

apply plugin: 'robospock'

Android gradle插件为我提供了构建变体任务,例如assembleProd,assembleProdDebug,assembleStageDebugTest。我可以在build.gradle中将一些内容传递给Robospocl,以便它可以参与构建变体吗?

目前,当我执行./gradlew robospok时,它无法找到com.acme.dev或com.acme.staging中定义的类

0 个答案:

没有答案