Can I integrate Jenkins and XCTest

7.7k Views Asked by At

Is it possible to use Jenkins with XCTest?

There's a ruby script (OCUnit2JUnit -- https://github.com/ciryon/OCUnit2JUnit) that parses OCUnit output and creates XML files that Jenkins can parse.

Is there something equivalent to handle the new XCTest output?

Right now, using Apple's continuous integration is not a possibility.

5

There are 5 best solutions below

1
Mark On

This is what I run on my Jenkins project after installing ocunit2junit on my build machine:

xcodebuild test -scheme <my_scheme> -configuration Debug -sdk iphonesimulator7.0 -destination OS=7.0,name="iPhone Retina (4-inch)" | ocunit2junit

I then added a Publish JUnit test result report as a post build action. Was a bit flakey at first (only creating the xml files when there was no post-build action), but after initiating the build directly on my build machine, it works.

0
cynistersix On

You need to add a shell script build phase.

First add the ocunit2junit gem to the build machine:

sudo gem install ocunit2junit

Then add the build phase shell script and make sure you're in the project directory when you execute the script:

xcodebuild -workspace yourWorkSpace.xcworkspace -scheme YourTestsScheme -configuration Debug clean test 2>&1 | ocunit2junit

Then make sure to add the publish JUnit test results post build action to the Jenkins job configured to find the output for ocunit2junit: **/test-reports/*.xml

0
Erik Mueller On

for me it doesn't work. also on the Github Welcome Page of the Projekt XCTest is not mentioned to be supported. So it appears that this is not supported

4
plluke On

Two options:

1) pipe your xcodebuild output into xcpretty and use their Junit formatter. Then Jenkins can publish that.

B) use xctool instead of xcodebuild. Xctool has built in Junit reporter you can specify for tests.

We've done both and they both work fine on Jenkins.

0
TeodorN On

I 've written a tool that parses the TestSummaries plist file from Logs/Test folder and generates the JUnit report xml file: (https://github.com/nacuteodor/ProcessTestSummaries). The generated report should be more accurate than xcpretty.