vendredi 15 mars 2019

How to set common unit test directory for build variants in Gradle Android

I have two modules app and common. Common has only debug/release build variants. App has four: realmDebug, realmRelease, roomsDebug and roomsRelease. All main unit tests are in app/src/test/java/. I would like to run them using gradle test task for realmRelease build variant.

Currently when I try to run $ ./gradlew app:testRealmReleaseUnitTest, only tests from common/src/test/java are launched. I think that gradle is looking for unit tests inside app/src/realmRelease directory which does not exists.

I tried to set sourceSets:

sourceSets {
    testRealmRelease {
        setRoot 'src/test'
    }
}

But even if :app:sourceSets prints correct config (in my opinion):

testRealmRelease
----------------
Compile configuration: testRealmReleaseCompile
build.gradle name: android.sourceSets.testRealmRelease
Java sources: [app/src/test/java]
Java-style resources: [app/src/test/resources]

$ ./gradlew app:testRealmReleaseUnitTest makes no difference.

Note that I do not want to compile rooms variants at all during running unit tests.

Aucun commentaire:

Enregistrer un commentaire