So I am running UIAutomation
on command line with
$ instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate
<path-to-your-app>/<appname>.app/ -e UIASCRIPT <path-to-your-js-test-file> -e
UIARESULTSPATH <path-to-results-folder>
This works fine and the simulator opens up, and the app runs, but gets stuck with this error.
Failed to authorize rights (0x2) with status: -60007
I believe it has something to do with the permissions.
How do I go about this ?
That's the answer I posted at Instruments via command line - jenkins
And here is even a blog post about Xcode command line authorization prompt error
I will explain it again here:
What I did was the following:
change value of allow-root to true
<key>system.privilege.taskport</key>
<dict>
<key>allow-root</key>
<false/> // change to -> <true>
<key>class</key>
<string>user</string>
<key>comment</key>
<string>Used by task_for_pid(...).
...
</dict>
Now I am being able to use jenkins to run my UIAutomation-Tests via Command Line Script
EDIT
To make jenkins recognize a successfull build, I have not a perfect solution but the following workaround:
...
echo "Run instruments simulator"
instruments -t "$ORDER_AUTOMATION_TEST_TEMPLATE_PATH" "$FILE_DEBUG_APP" -e UIASCRIPT "$ORDER_AUTOMATION_TESTSCRIPT_PATH" -e UIARESULTSPATH "$DIRECTORY_INSTRUMENTS_RESULT"
returnCode=0
if test -a "Run 1/Assertion failed.png"; then
echo "failed"
returnCode=1
else
echo "passed"
returnCode=0
fi
rm -fR "Run 1"
rm -fR "instrumentscli0.trace"
echo "Removing app dir"
echo "$FILE_APPLICATIONS"
rm -fR "$FILE_APPLICATIONS"
echo $returnCode
exit $returnCode
EDIT 2 Better way to check if automation test did run successfully:
# cleanup the tracefiles produced from instruments
rm -rf *.trace
##kill simulator afterwards
killall "iPhone Simulator"
##check if failures occured
# fail script if any failures have been generated
if [ `grep "<string>Error</string>" "$WORKSPACE/Automation Results/Run 1/Automation Results.plist" | wc -l` -gt 0 ]; then
echo 'Build Failed'
exit -1
else
echo 'Build Passed'
exit 0
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With