Search code examples
androidgradleinstrumentation

connectedAndroidTest and release build type


I'm using gradle:1.2.3

I would like to run my androidConntectTests (instrumentation tests) on release (signed, minified) configuration, but I cannot.

My build types:

buildTypes {
    debug {         
        minifyEnabled false
        debuggable true
    }

    robotium {
        debuggable true
        minifyEnabled true
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

    release {
        minifyEnabled true
        debuggable false
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

I have read, that those tests can only be run on debbugable configurations, so I made "robotium" build type (see above), but it still does not work.

When I try calling "gradle tasks" it shows only connectedAndroidTest-Flavour-Debug, and calling "connectedAndroidTest-Flavour-Release/Robobium" simply fails with "task XXX not found in root project".

Is there any way to make instrumentation tests run on diffrent build type?


Solution

  • The android gradle plugin will create test variants for all your flavors. To switch the build type used you can do this, as stated in the documentation

    Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:

    android {
        ...
        testBuildType "staging"
    }