Hi there! Is there any way to set the current/defa...
# multiplatform
m
Hi there! Is there any way to set the current/default locale when run
gradle check
? I have some logic that rely on `Locale`/`NSLocale` and the unit tests are using the machine locale which may be out of control..
1
j
Both have mutators you can use to set the global default. Just be sure to capture the default, change default, and then try/finally to reset it back to the real value.
m
yeah, I know I can try to handle it directly in tests (setup/teardown), but I wondered if there is some kind of global mechanism to set the language globally (i.e. as gradle task argument or something)
j
For the JVM you can use
-D
flags which are documented here: https://www.oracle.com/technical-resources/articles/javase/locale.html#using
I don't know anything about NSLocale other than you can mutate it
m
Ok, thanks. I’ve handled it actualy by DI + mock the locale in test
j
DI + a constant locale value is the way to go. Hopefully not an actual mock.
m
Yup, this is how we did it! 🙂