✅ Add JUnit Rule to override locales during tests
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Jul 2022 21:24:13 +0000 (23:24 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Jul 2022 21:24:13 +0000 (23:24 +0200)
commitb3c31725b779d0287fff79728227556751f837f2
treef1810e342bf43594cc19acd5f360aa74a578d53a
parent234fe1a5855cd14526059625881ee6722ffab332
✅ Add JUnit Rule to override locales during tests

Some tests fail when run with a non-English locale. This was found by debbiedub (see https://github.com/Bombe/Sone/pull/23) but their proposed solution was not quite to my liking.

This TestRule will store the JVM’s current default locale and set a custom locale before running a test. After the test the previous locale will be restored, in order not to mess up any other tests.
src/test/kotlin/net/pterodactylus/sone/test/OverrideLocale.kt [new file with mode: 0644]