iOS Localization and Internationalization Testing with XCUITest

Published by Shashikant Jagtap on

It’s very common to find an iOS applications in different languages and supporting different countries. The brands needs to intruduce their business  to the locals in the language that is truly local and that’s the way to connect and create value out of the iOS app. It’s essential to develop and test an iOS app for different countries and locales. You can read more about locatization and internaiozation testing here but for this post we will consider how to use XCUITest to perform locatization and internaiozation testing. It’s assumed that you have basic understanding of using XCTest Framework for this post.

Process Arguments and environments

As you might aware that XCUITest launch separate proxy app for testing the real app, this means the only way real app can interact with proxy app by passing NSProcessInfo.processInfo().arguments  and NSProcessInfo.processInfo().environment  to the proxy application. The XCUITest application can then use those arguments and environments as  XCUIApplication().launchArguments and  XCUIApplication().launchEnvironment  respectively. We can use those arguments while launching and app.

Apple has provided two very convinient process arguments to deal with internationalization and localization testing those are

  •  -AppleLanguages
  •  -AppleLocale

We can pass different locales and languages value to above process arguments in the setup method of XCTest.

XCUI and Process Arguments

XCUI Test has a setup method for each test suit class. We can pass process arguments in the setup method to launch application for France locale and language like this

Once, We have that setup we can see that our application is launched in the French language and France Locale. We can use different countries and locales which are available in the simulator or devices. In some cases, you have to pass those arguments to the ‘Test’ option in the  XCUI Scheme  itself.

Apple has documentation about setting up app for the Internationalized app.

Things to Remember

There are few things we need remember while using internationalised testing

  • Make sure application launch in the fresh simulator without any cache otherwise we might get previous state of simulator. It’s good idea to clear simulator content before starting test suite.
  • Once we have executed test in simulator or device it can carry the same language and locale to the next XCUI test case. There is no way to clear the simulator content in between the test cases so it’s good idea to create new scheme for each country and locale.

Conclusion

XCUITest can be used to test iOS app in the different languages and locales to get confidence that application works as expected in other languages as well. What are your experiences testing  iOS app for the different languages and locales, share in the comments below.