David Holas
01/25/2024, 7:50 AMCustomFormatter
interface that uses NumberFormatter on android side which needs withLocale
method to be mocked. I can make NumberFormatter
a dependency of AndroidCustomFormatter
but still MocKMP
cannot mock NumberFormatter
because it is not an interface.
I could mock the whole CustomFormatter, but that kinda defeats the purpose. Is there any way around it?
Thank you
https://pl.kotl.in/-SpBAWQl-spand
01/25/2024, 7:55 AMspand
01/25/2024, 7:58 AMspand
01/25/2024, 7:59 AMConfig
alsoDavid Holas
01/25/2024, 7:59 AMMethod withLocale in android.icu.number.NumberFormatter not mocked.
David Holas
01/25/2024, 8:02 AMIts a bit difficult to know without havingThere is actually noalsoConfig
Config
, I just pass some parameters regarding the formatting, like units the formatter should use, etc. I didn't wanna write the all out as they are really not relevantDavid Holas
01/25/2024, 8:10 AMCreate a common test and one for each platformI don't really understand how to make it work. Should I then override the
@Test fun
inside the subclass on android side?spand
01/25/2024, 8:12 AMspand
01/25/2024, 8:13 AMspand
01/25/2024, 8:13 AMwithLocale(config.locale)
David Holas
01/25/2024, 8:19 AMDavid Holas
01/25/2024, 8:36 AMLocale
to the CustomFormatter
is super complex and would require me to add multiple classes to the example just for that. Also the source of locale is irrelevant in this, the issue persists even with Locale.ENGLISH
. I also removed the Config
entirely as it just does not exist in my code.
https://pl.kotl.in/yoeYRvCmKspand
01/25/2024, 8:37 AMDavid Holas
01/25/2024, 8:38 AMIt is on ios, but on android it says:
Copy codeMethod withLocale in android.icu.number.NumberFormatter not mocked.
David Holas
01/25/2024, 8:58 AMDavid Holas
01/25/2024, 9:03 AMIOSCustomFormatterTest
is fine, but running AndroidCustomFormatterTest
crashes with
Method withLocale in android.icu.number.NumberFormatter not mocked.
https://pl.kotl.in/OZIRgOKcVspand
01/25/2024, 9:14 AMDavid Holas
01/25/2024, 1:58 PMDavid Holas
01/26/2024, 12:30 PMspand
01/26/2024, 12:31 PM