OCUnit : changing the user's locale for testing

939 Views Asked by At

This is a simple question : is it possible to change the locale while unit testing ?

I'd like to check that my label is "Monday" in english and "lundi" in french for example.

1

There are 1 best solutions below

1
On

The situation you describe sounds more like an integration test than a unit test; you're changing the environment in which the app runs and ensuring that the app's behaviour changes accordingly. It's the sort of thing I'd check with UIAutomation.

In a unit test situation, you might have a method that prepares the label text: you can create arbitrary NSLocale instances, and assert that the correct strings table is used for each locale in your test fixtures.