Running iOS UIAutomation tests from Jenkins
Asked Answered
P

3

7

For a while now I've been trying to work out how to run UIAutomation tests from Jenkins - every time I run the build, it builds fine, then it runs my instruments command (using the same command as detailed here ( Can Instruments be used using the command line?) and jenkins just hangs, well the whole machine does, and when I look at activity monitor I can see an instruments process using 2gb of memory.

When I set up jenkins, I original ran it as from a hidden user - this presented some challenges with jenkins being a deamon and not being able to access the window server. I then decided to change the jenkins account to a normal user, logged in and ran instruments from the command line - this worked fine.. but still had no luck with running it from jenkins.

I have set the jenkins account as a developer - no admin though

Please let me know if there's anything else that I could try, or if anyone has got this running successful your guidance would be much appreciated - Thanks

Penna answered 2/5, 2012 at 19:25 Comment(2)
How do you run (i.e. start up) Jenkins?Clementeclementi
Its running as a deamon, so it loads at startup - if I need to stop or restart it I use launchctlPenna
C
1

So if you run it as a daemon, first thing to check what happens if you run Jenkins in the foreground The simplest way to do it is with java -jar jenkins.war [other options] command (see this document).

Clementeclementi answered 2/5, 2012 at 20:19 Comment(3)
Brilliant thanks - all running ok now - is there a more elegant way to start jenkins like this?Penna
The only thing I can think about is to put it in a script and to run that script from a login hook.Clementeclementi
Thanks - added it as a login hook - well into the launch agent and everything is working now - thanksPenna
S
4

Jenkins on OS X is started from a launchd script and will run as "daemon" by default. The thing to do is change the user in the launched script.

First, get Jenkins ready to shutdown (in "Manage Jenkins" in the GUI).

Then unload the job from launchd, like so:

$ sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

Then edit the "UserName" property in the launchd plist, using the user which you want to run jenkins. There's also a GroupName property, which you may want/need to adjust accordingly with your user's group.

Finally, reload Jenkins with:

$ sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Hope that helps!

Seftton answered 13/6, 2012 at 3:30 Comment(2)
This worked perfectly for me. By default the GroupName was set to daemon and that was crashing the ios simulatorPinnatisect
We followed this solution and it worked but one thing to note - It seems in newer versions of xcode you need to remove the <key>SessionCreate</key> and <true\> value from your org.jenkins-ci.plist see here for more details: cimgf.com/2015/05/26/setting-up-jenkins-ci-on-a-mac-2Priapus
C
1

So if you run it as a daemon, first thing to check what happens if you run Jenkins in the foreground The simplest way to do it is with java -jar jenkins.war [other options] command (see this document).

Clementeclementi answered 2/5, 2012 at 20:19 Comment(3)
Brilliant thanks - all running ok now - is there a more elegant way to start jenkins like this?Penna
The only thing I can think about is to put it in a script and to run that script from a login hook.Clementeclementi
Thanks - added it as a login hook - well into the launch agent and everything is working now - thanksPenna
S
0

Maybe you can use this https://github.com/houlianpi/robot4ios.

Then in jenkins execute shell:

sh setup.sh
sh runTests.sh ./sample/alltests.js "/Users/komejun/Library/Application Support/iPhone Simulator/5.0/Applications/1622F505-8C07-47E0-B0F0-3A125A88B329/Recipes.app/"

and the report will be auto create in ./ynmsk-report/test.xml

Smelt answered 7/5, 2012 at 2:33 Comment(2)
That sounds interesting, will robot4ios manage setup/teardown between tests too? I take it the xml output is compatible with jenkins so that the output can be displayed?Penna
ynm3k had been upgraded in another fork github.com/douban/ynm3k, which replaced runTests.sh with test_runner/run. Not sure if the sample in the old project could still work.Scatology

© 2022 - 2024 — McMap. All rights reserved.