简体   繁体   English

Xcode 7 UI测试目标语言环境和区域设置

[英]Xcode 7 UI Testing target locale and region settings

I'm trying to set the language and the region of my UI Testing target, and unfortunately it doesn't seem to work. 我正在尝试设置我的UI测试目标的语言和区域,不幸的是它似乎不起作用。

I've tried both ways, first: 我试过两种方式,首先:

  • Product | 产品| Scheme | 方案| Edit Scheme 编辑方案
  • Run | 运行| Options 选项
    • Application Language: French 应用语言:法语
    • Application Region: France 应用地区:法国
  • Test | 测试| Arguments 参数
    • Use the Run action's arguments and environment variables: Checked 使用Run操作的参数和环境变量:已选中

And I try this other way: 我试着用另一种方式:

  • Product | 产品| Scheme | 方案| Edit Scheme 编辑方案
  • Test | 测试| Arguments 参数
    • Use the Run action's arguments and environment variables: Unchecked 使用Run操作的参数和环境变量:未选中
    • Arguments passed at launch: 发布时通过的论据:
      • -AppleLanguages (French)
      • -AppleLocale fr_FR

Each way resulting in the UI Testing still happening in English. 导致UI测试的每种方式仍然以英语发生。 Moreover, when I hit the record button, it runs in French... 而且,当我按下录音按钮时,它会以法语运行...

So if I do something wrong, I would be happy to know! 所以,如果我做错了什么,我很乐意知道!

Thanks in advance! 提前致谢!

I have figured it out. 我已经弄清楚了。 I set the locale settings in the launchArguments for testing temporary in Xcode. 我在launchArguments中设置了locale设置,以便在Xcode中进行临时测试。

override func setUp() {
    super.setUp()

    // Put setup code here. This method is called before the invocation of each test method in the class.

    // In UI tests it is usually best to stop immediately when a failure occurs.
    continueAfterFailure = false
    app = XCUIApplication()
    app.launchArguments = [
        "-inUITest",
        "-AppleLanguages",
        "(de)",
        "-AppleLocale",
        "de_DE"
    ]

For CI I use fastlane from Felix Krause and get localized screenshots with snapshot. 对于CI我使用来自Felix Krause的fastlane并获得带有快照的本地化截图。

Try changing the specs on the simulator. 尝试更改模拟器上的规格。 It worked for me every time. 它每次都对我有用。

On Simulator: Settings > General > Language & Region > iPhone Language --> change here 在模拟器上:设置>常规>语言和区域> iPhone语言 - >在此处更改

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM