fresh-guitar-29838
02/05/2025, 1:02 AMancient-car-96302
02/05/2025, 9:10 AMval mockedResult = GBFeatureResult(
gbValue = GBNumber(5),
source = GBFeatureSource.defaultValue,
);
every { mockGrowthBookSdk.feature(featureName) } returns mockedResultfresh-guitar-29838
02/05/2025, 7:09 PMfeature() function, it's instead calling the inline one.fresh-guitar-29838
02/05/2025, 9:52 PM@Test
fun `mock growthbook sdk feature`() {
val featureResult = GBFeatureResult(gbValue = GBNumber(5), source = GBFeatureSource.defaultValue)
val gb: GrowthBookSDK = mockk {
every { feature("key") } returns featureResult
}
val value = (gb.feature("key").gbValue as? GBNumber)?.value
assertThat(value).isEqualTo(5)
}ancient-car-96302
02/06/2025, 9:29 AMancient-car-96302
02/06/2025, 9:45 AMforcedFeature fieldancient-car-96302
02/06/2025, 10:20 AMforcedFeatures in order to achieve it I changed visibility modifier. It seems like you have no ability to change visibility modifier, you have only ability to change the version of GBancient-car-96302
02/06/2025, 10:21 AMancient-car-96302
02/06/2025, 10:26 AMancient-car-96302
02/06/2025, 10:34 AMancient-car-96302
02/06/2025, 11:03 AMfresh-guitar-29838
02/07/2025, 12:17 AMfeature() methods?
that might be a better solution than exposing forcedFeatures 😕ancient-car-96302
02/07/2025, 7:38 AMfeature() to what? why public visibility modifier is bad? No need for encapsulation for forcedFeatures (it is not something that can be broken). When a class has public dependencies, this class is suitable for testingancient-car-96302
02/07/2025, 7:49 AMancient-car-96302
02/28/2025, 1:06 PM