We define features using enums, and provide a default value.
enum class Feature(
val enabled: Boolean,
val remoteConfigKey: String = ""
) {
SecureCall(false, "secure_call"),
Telemedicine(true, "telemedicine_enabled")
}
We check if a feature is enabled or not, using Features
class. Since this class is part of Dagger graph we can inject it.
fun call() {
if (features.isEnabled(SecureCall))) {
// Handle code
}
}
Overriding this value in tests is very simple.
@Test
fun `the feature is overriden in this test`() {
Features.overrides[Feature.SecureCall] = true
}
You can read more about this usage here