Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCTest output to a file

Tags:

xctest

I am able to run XCTests using xcodebuild test command. But when I run this command it outputs the build log and then there is log from test at the end. Is there a way where I can redirect only the output of test (no build logs) to a separate file?

I couldn't find anything in xcodebuild command.

Regards Dev

like image 249
dev Avatar asked Feb 26 '14 19:02

dev


2 Answers

You can use ocunit2junit https://github.com/ciryon/OCUnit2JUnit to parse the build log output into junit xml for use with Jenkins. This works with XCTest as well.

xcodebuild test -scheme "MyScheme" -destination "platform=iOS,id=UDID_OF_DEVICE" -derivedDataPath "$(pwd)" 2>&1 | tee out.txt
cat out.txt | tools/ocunit2junit

This outputs junit xml to test-reports by default. If you don't want junit xml then you can still use ocunit2junit as a reference for parsing the build output.

like image 181
Gardner Bickford Avatar answered Nov 03 '22 22:11

Gardner Bickford


xcpretty has a -r option that outputs the test results into a format of your choice: https://github.com/supermarin/xcpretty

like image 5
Apophenia Overload Avatar answered Nov 03 '22 23:11

Apophenia Overload