roberth
roberth

Reputation: 11

Printing to the Xcode (XCTest) UITest Report

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")

I'm happy to make any necessary clarifications.

Upvotes: 1

Views: 6108

Answers (2)

Titouan de Bailleul
Titouan de Bailleul

Reputation: 12949

You can use XCUITestHTMLReport. It creates an Xcode like HTML report

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

Upvotes: 0

noor
noor

Reputation: 3004

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

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

gem install xcpretty

Upvotes: 2

Related Questions