Unit-testing – What practices exist for locale-specific unit testing

localizationunit testing

We recently discovered a locale specific issue in our application and while it was easy to fix (once we figured out what was going on), it got the team I'm on thinking about unit testing practices in this regard.

We would like to catch these issues sooner, ideally before they're discovered by a customer, and we want to protect ourselves from reintroducing locale specific bugs in the future, but duplicating every unit test in at least one other culture seems like a lot of overhead.

How do you or how would you approach multi-locale unit testing?

Best Answer

Generally you will not need to duplicate every unit test. You should identify what is really dependent on the locale (good checklist is here). Many things related to internationalization are subject to the higher level of testing then unit-test.

If you are dealing with the string data that may come in different encodings, then you can utilize "data driven testing", i.e. passing data in different encodings to the same test method. For Java the TestNG is best suitable for this.

Another possible problem is the date/time formatting and parsing. Most locales uses : to separate time elements, but there are ones who uses dots and Brazilians uses h m and s (12h15m30s). This also can be used by passed data in different locales - you do not need to test all of them.

And testing GUI with right-to-left locales is usually not a subject of unit testing.

The bottom line is that you need to identify what data in your unit tests is locale-specific and use data-driven testing (data providers) to supply this data to your tests.

Related Topic