【发布时间】:2020-07-03 11:55:49
【问题描述】:
我已经为每个模块实现了 XCTest 案例,我正在寻找如何知道启动图像是使用 xctest 案例添加到 xcasset 中的。
【问题讨论】:
-
我赞成科学怪人的回答,但想注意 UI 测试不是为这样的检查而设计的。如果你能更多地讲述你的任务,也许你会找到更好的解决方案。
标签: ios swift xcuitest xctestcase
我已经为每个模块实现了 XCTest 案例,我正在寻找如何知道启动图像是使用 xctest 案例添加到 xcasset 中的。
【问题讨论】:
标签: ios swift xcuitest xctestcase
不完全确定你在这里做什么。
您可以通过检查捆绑图像的名称来检查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)
【讨论】: