英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论