I found a way to do it here
Create another one buildType(whose name should not begin with:) testand pass its name to the property:
android {
testBuildType "staging"
def INTEGER= "integer"
def VARIABLE = "variable"
buildTypes {
debug {
buildConfigField BOOLEAN, VARIABLE, "2"
}
staging {
initWith(buildTypes.debug)
buildConfigField BOOLEAN, VARIABLE, "4"
}
}
}
Tests should be performed against staging buildType.