I'm currently writing UITests for an iPhone app and currently use NSLog to print when there is an unexpected situation in helper methods, this causes a false assertion at the test level so it's clear where the error occurs in the test. Then I just read the log to see what the issue was. Is there a way to print this to the test report so I can check all failures once all the tests run? Right now the only log results are the ones that the test generates automatically (such as "Tap 'myButton' Button" or "Find: Elements matching typeButton")
我正在为iPhone应用程序编写UITests,并且当帮助方法中出现意外情况时,当前使用NSLog进行打印,这会在测试级别导致错误断言,因此很清楚测试中出现错误的位置。然后我只是阅读日志以查看问题所在。有没有办法将其打印到测试报告中,以便在所有测试运行后检查所有故障?现在唯一的日志结果是测试自动生成的结果(例如“点击'myButton'按钮”或“查找:匹配typeButton的元素”)
I'm happy to make any necessary clarifications.
我很乐意做出任何必要的澄清。
2 个解决方案
#1
1
First of all, you can check your
首先,你可以查看你的
TestSummaries.plist file
which is generated in
这是生成的
/Users/username/Library/Developer/Xcode/DerivedData/project-name/Logs/Test/TestSummaries.plist
If you open the file in xcode, you will see all your test summaries but in little bit bored way. You have to expand all the nodes. But you can make an html report by using
如果您在xcode中打开文件,您将看到所有测试摘要,但有点无聊。您必须扩展所有节点。但你可以使用。做一个HTML报告
xcpretty
just use this command in your terminal
只需在终端中使用此命令即可
xcodebuild test -project projectname -scheme schmefilename -destination 'platform=iOS Simulator,name=iPad 2' | xcpretty --report html --output outputfolderdestination/report.html
To install xcpretty, use the below command
要安装xcpretty,请使用以下命令
gem install xcpretty
#2
0
You can use XCUITestHTMLReport. It creates an Xcode like HTML report
您可以使用XCUITestHTMLReport。它创建了一个类似HTML报告的Xcode
You use it like this
你这样使用它
$ xcodebuild test -workspace XCUITestHTMLReport.xcworkspace -scheme XCUITestHTMLReportSampleApp -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0' -resultBundlePath TestResults
$ ./xchtmlreport -r TestResults
Report successfully created at TestResults/index.html
#1
1
First of all, you can check your
首先,你可以查看你的
TestSummaries.plist file
which is generated in
这是生成的
/Users/username/Library/Developer/Xcode/DerivedData/project-name/Logs/Test/TestSummaries.plist
If you open the file in xcode, you will see all your test summaries but in little bit bored way. You have to expand all the nodes. But you can make an html report by using
如果您在xcode中打开文件,您将看到所有测试摘要,但有点无聊。您必须扩展所有节点。但你可以使用。做一个HTML报告
xcpretty
just use this command in your terminal
只需在终端中使用此命令即可
xcodebuild test -project projectname -scheme schmefilename -destination 'platform=iOS Simulator,name=iPad 2' | xcpretty --report html --output outputfolderdestination/report.html
To install xcpretty, use the below command
要安装xcpretty,请使用以下命令
gem install xcpretty
#2
0
You can use XCUITestHTMLReport. It creates an Xcode like HTML report
您可以使用XCUITestHTMLReport。它创建了一个类似HTML报告的Xcode
You use it like this
你这样使用它
$ xcodebuild test -workspace XCUITestHTMLReport.xcworkspace -scheme XCUITestHTMLReportSampleApp -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0' -resultBundlePath TestResults
$ ./xchtmlreport -r TestResults
Report successfully created at TestResults/index.html