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
Eugen Martynov
09/17/2024, 10:14 AM
I would probably go to the interface and platform specific implementation in this case
Eugen Martynov
09/17/2024, 10:15 AM
Or other way to inject locale dependency
Eugen Martynov
09/17/2024, 10:16 AM
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
Guyaume Tremblay
09/17/2024, 11:40 AM
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..