【问题标题】:How to check launch image is added in application using XCUITest? [closed]如何使用 XCUITest 检查应用程序中添加的启动图像? [关闭]
【发布时间】:2020-07-03 11:55:49
【问题描述】:

我已经为每个模块实现了 XCTest 案例,我正在寻找如何知道启动图像是使用 xctest 案例添加到 xcasset 中的。

【问题讨论】:

  • 我赞成科学怪人的回答,但想注意 UI 测试不是为这样的检查而设计的。如果你能更多地讲述你的任务,也许你会找到更好的解决方案。

标签: ios swift xcuitest xctestcase


【解决方案1】:

不完全确定你在这里做什么。

您可以通过检查捆绑图像的名称来检查LaunchImage 是否可用。

func checkIfLaunchImageAvailable() -> Bool {
    for imageName in Bundle.main.paths(forResourcesOfType: "png", inDirectory: nil) {
        if imageName.contains("LaunchImage"), UIImage(named: imageName) != nil {
            print("Launch image is available!")
            return true
        }
    }
    return false
}

并且可以使用XCTAssertTrue进行检查:

XCTAssertTrue(checkIfLaunchImageAvailable)

【讨论】:

  • 不客气!如果有帮助,请不要忘记投票并标记为正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-08
  • 1970-01-01
  • 1970-01-01
  • 2012-05-05
  • 1970-01-01
  • 1970-01-01
  • 2016-10-08
相关资源
最近更新 更多