Hi everyone! Is it possible to override an `actual...
# test
g
Hi everyone! Is it possible to override an
actual
in
*unitTest
? My situation is that I have an
expect/actual
in an
object
which return the user language and I have a test which look for a date (like
January 1st
) My date formater is using this
object
and, mokkery can't mock an object. Now, if my computer is not in english but my CI is, my test will fail... I tried to put an actual in
androidUnitTest
but it complain that there is no expect in
commonTest
... Do you think of something else please ?
e
I would probably go to the interface and platform specific implementation in this case
Or other way to inject locale dependency
Not recommended - you can have global locale variable that is initiated with default locale and in test you set it before the test execution.
g
Thanks @Eugen Martynov for your input. I did think about injection but in this case, I can't inject any dependency (it's a viewmodel calling an extension on LocalDateTime ). So I end up with calling the date formatter in the test. All this is a workaround until jetbrains offer something to localize easily the LocalDateTime so..