0

I have been going around in circles with this. Basically I have Jenkins on one machine, and a Mac server as a separate iOS build server. I need to be able to run unit tests and then code coverage from Jenkins on the Mac Mini. I have a script which will run the tests, and it works perfectly when it is run from the command line on the machine itself. The problem is when I try to run it from Jenkins the actual tests don't run. It runs through the build process and then reports "Test Succeeded" without actually running any tests. Basically I need to be able to run the tests when I ssh into the machine.

I am using gcovr to create the xml file for the unit test coverage. I considered using xctool, which seems to run, but only creates gcda files, and not gcno so I can't get that working wither.

Banging my head against the wall at this point so any help is appreciated.

The command I am running: xcodebuild -workspace MyProject.xcworkspace -scheme MyProject -sdk iphonesimulator test

which runs fine when run from the command line while logged into the machine, but does not run any tests when I ssh in.

benny_bates
  • 65
  • 1
  • 6

2 Answers2

0

The problem was that I was pulling up the simulator from two different places. So, if I ran the script directly on the build machine, the simulator would come up. If I then tried to run the script over ssh, it would try to pull up the simulator, which was already up and locked.

Solution? Top of the script, kill any simulator that was running:

pkill -i simulator

Might not be elegant, but does the trick.

benny_bates
  • 65
  • 1
  • 6
0

It seems that you have to run xcode unit tests from a process which was started from the user's GUI (for example with a ~/Library/LaunchAgents agent/daemon).

You can use a server or daemon (which is started from the GUI / Terminal or with LaunchControl) to run your unit tests. Here's a server written in Go which does exactly this.

Viktor Benei
  • 3,447
  • 2
  • 28
  • 37