I have an open source library which has plenty of unit tests that compare string forms of numbers.
These tests pass fine in en-GB, en-US and other cultures where numbers are generally written in the form 1,234.00.
However in cultures such as Germany and France, these values are formatted differently, and the tests fail.
How can the jUnit tests be forced to run as en-GB?
EDIT this kind of thing is available in NUnit.
I’m not sure it’s standard for all JVMs, but using Oracle’s JVM on Windows, you can use the user.language and user.country System properties to set the locale when starting the JVM:
You can also, of course, set the default locale in Java, using
Note that
Double.toStringis locale-independent, though.