ios - 打印到 Xcode (XCTest) UITest 报告

标签 ios swift xcode xctest xcode-ui-testing

我目前正在为一个 iPhone 应用程序编写 UITests,并且当前使用 NSLog 在辅助方法中出现意外情况时进行打印,这会导致测试级别的错误断言,因此很清楚测试中发生错误的位置。然后我只是阅读日志以查看问题所在。有没有办法将其打印到测试报告中,以便我可以在所有测试运行后检查所有失败?现在唯一的日志结果是测试自动生成的结果(例如“Tap 'myButton' Button”或“Find: Elements matching typeButton”)

我很乐意做出任何必要的澄清。

最佳答案

首先,你可以检查一下你的

TestSummaries.plist file

产生于

/Users/username/Library/Developer/Xcode/DerivedData/project-name/Logs/Test/TestSummaries.plist

如果你在 xcode 中打开文件,你会看到所有的测试摘要,但有点无聊。您必须展开所有节点。但是你可以使用

xcpretty

只需在您的终端中使用此命令

xcodebuild test -project projectname -scheme schmefilename -destination 'platform=iOS Simulator,name=iPad 2' | xcpretty --report html --output outputfolderdestination/report.html

要安装 xcpretty,请使用以下命令

gem install xcpretty

关于ios - 打印到 Xcode (XCTest) UITest 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38792298/

相关文章:

iphone - 在 'splitViewBarButtonItem' 类型的对象上找不到属性 'id<UISplitViewControllerDelegate>'

ios - iOS6 中的 UISegmentedControl 图像突出显示错误

ios - 如何获取属性字符串的字符串范围?

ios - 计算MBProgressHUD下载进度

iphone - 在 UISplitViewController 中设置主视图的显示/隐藏启用,仅用于横向模式下的一个 View Controller

iphone - 提取部分 NSString

ios - Storyboard "show"segue 在更新到 xcode7 后不起作用(仅在一种情况下)

ios - 使用分段控制 Swift 3

JSON后台处理和本地通知

ios - 使用默认值初始化 ViewModel