Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I create different testersGroups depending on build type?` #28

Open
dant3 opened this issue Dec 4, 2014 · 2 comments
Open

How can I create different testersGroups depending on build type?` #28

dant3 opened this issue Dec 4, 2014 · 2 comments

Comments

@dant3
Copy link

dant3 commented Dec 4, 2014

Hi

I want to have different sets of groups for different build types/flavors.

Like if debug builds were available only to devs and qa, but release was as well available for beta-testers.

I can't think of how can I do this without suffering pain or supplying list from the outside which still does not works if I build multiple targets at once.

Is this possible, at least with some coding involved?

@IonutGavris
Copy link

Hi @dant3,

One solution would be to send the build type to the gradle script, as an command line argument.

Modify your build.gradle file to contain the following:

android {
    buildTypes {
        release {
            setTestFairyGroups("release", "dev, qa, owner")
        }
        staging {
            setTestFairyGroups("debug", "dev, qa")
        }
    }
}

def setTestFairyGroups(String buildType, String testGroups) {
    if (project.hasProperty("testBuildType")) {
        if (project.property("testBuildType").equals(buildType)) {
            testfairyConfig.testersGroups(testGroups)
        }
    }
}

From command line you use it like this:

gradlew testfairyRelease -PtestBuildType = "release"

or

gradlew testfairyStaging -PtestBuildType = "staging"

@mikekudzin
Copy link

mikekudzin commented Jan 25, 2017

You may try the following script. It works for us

afterEvaluate {
    android.applicationVariants.all { variant ->
        def fairyTask = tasks.findByName("testfairy${variant.name.capitalize()}")
        if (fairyTask) {
            def testGroups
            if (variant.name.capitalize().contains("demo".capitalize())) {
                testGroups = "demo"
            } else {
                testGroups = "dev"
            }
            fairyTask.doFirst {
                testfairyConfig.testersGroups(testGroups)
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants