更改每个案例中的UI测试区域

huangapple go评论55阅读模式
英文:

Change region in UI testing for each case

问题

我正在使用swift-snapshot-testing库进行快照测试。对我来说很重要的是使用不同的本地化来进行所有测试,以检查当文本更改时所有的UI。例如,UI测试方案设置为在德语语言和地区运行,在某些测试中,我也想查看英文版本,我已经做到了。但它仍然无法在德语语言上运行,有人可以给我一些提示吗?谢谢

英文:

i am using swift-snapshot-testing library to do snapshot testing. It's important for me to do all the tests with different localization to check all the UIs when the text is changed.
For example, the UI testing scheme is set to run on German language and region, In some tests, I want to see the english version as well and I did that

class BackgroundViewFactoryTests: XCTestCase {
    
    override class func setUp() {
        SnapshotTesting.diffTool = "ksdiff"
    }
    
    func test_backgroundView_contact_eng() {

        
        continueAfterFailure = false

        XCUIApplication().launchArguments += ["-AppleLanguages", "(en)"]

        XCUIApplication().launchArguments += ["-AppleLocale", "en_UK"]

        XCUIApplication().launch()
        
        let view = BackgroundViewFactory()
        view.backgroundColor = .darkGray
        assertSnapshot(matching: view, as: .image, record: false)
        
    }
}

But it's still not working and run on German language, could anyone give me hit?
Thanks

答案1

得分: 0

快照测试应该对所有字符串保持中立。如果更改一个翻译,您不希望出现测试失败。将翻译作为单独的单元测试进行测试。

英文:

The snapshot tests should be agnostic to all Strings. You don’t want breaking tests if you change one translation.
Test the translation in a separate UnitTest.

huangapple
  • 本文由 发表于 2023年2月7日 01:12:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75364477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定