tags:

views:

3168

answers:

9

Hi there, I would like to have my iphone test app to be tested automatically in an IPhone. The following are the steps I would like to have: 1. compile, link and code sign the iphone app (Xcodebuild) 2. upload the newly built app to iphone 3. run the uploaded app in iphone automatically 4. collect the result from the gdb console 5. close the app

Right now, I have problem with step 2 and 3 where I cannot do it automatically (I can do it from XCode via "Build and Debug" button. This, however, will require manual clicking).

I did some research on automator and it does not answer my problem. Another option I am thinking about is to have the app compiled for iphone simulator and run it from there, but I am not sure how accurate the test result will be comparing to the real device.

I am new to Mac/IPhone development, perhaps someone has a better way of testing this. Any feedback and input are welcome. Thanks.

Regards, chuan

+2  A: 

The tool you probably want to use for the build and install is Applescript. Something like:

tell application "Xcode" to launch

I'm not pretending that this is a complete answer; there are still a lot of things to work out. But Applescript is going to be one of your key tools I believe.

Rob Napier
thanks for the pointer. I managed to launch XCode using the applescript. Right now, I have to figure out what is the syntax to click select the right project and click "build and go". It will be quite a while before I will come out with anything useful.
chuan
Don't think of it as "click build and go." You need to think about the events. If you get "click" in your head, you'll often go down the wrong road. The command for build is "build". You'll want to spend a lot of time in the Applescript Editor's "Open Dictionary" to look at what Xcode provides. You'll want commands like 'build using build configuration named "Release" of first project'. 'launch' is what will run it. 'set active architecture' may also be important. The harder question is how to easily get the console output.
Rob Napier
the console output can be done this way:in terminal type the following commands: defaults write com.apple.Xcode PBXGDBDebuggerLogToFile YES defaults write com.apple.Xcode PBXGDBDebuggerLogFileName <path to my gdb output file>With this, I write a python script to call build, and run the test app. Then pick up the output log after the testing.Btw, thanks again for the Applescript pointers. I shall try it today.
chuan
Hi Rob, I tried out the AppleScript as what you have recommended and it is quite easy to do it!The following is my AppleScript:<code>tell application "Xcode" tell project "iphone_test_client" debug end tellend tell</code>It is not the finish product yet (need to sort out the AppleEvent timeout issue), but it does the job :) . The next step for me is to integrate this into CruiseControl. Thanks for your help. This helps me tremendously.
chuan
+1  A: 

There's a command line tool "xcodebuild" you can call to kick off an XCode build without it being open. There are flags you can use to set targets and so on.

Kendall Helmstetter Gelner
thanks for the help. xcodebuild will just build the binary and it will not upload the newly compiled binary to iphone. If there is a flag/option that I need to specify to make it work, I would love to know about it.
chuan
A: 

Dr Nic's testing with Ruby may help with some of this

Chris Kimpton
A: 

Could you add a build phase to the target that runs a script to upload the binary to the iphone?

Right click the target, Add->New Build Phase->New Run Script Build Phase

David Sykes
+5  A: 

The comment section does not provide a good way of display the solution properly. Here is the summary of answer.

The task of building IPhone app, uploading and trigger the debug process on IPhone is done via AppleScript. Here is how the AppleScript looks like:

tell application "Xcode"
    open "Users:chuan:Desktop:iphone_manual_client:iphone_manual_client.xcodeproj"
    tell project "iphone_manual_client"
     clean
     build
     (* for some reasons, debug will hang even the debug process has completed. 
        The try block is created to suppress the AppleEvent timeout error 
      *)
     try
       debug
     end try
    end tell
    quit
end tell

AppleScript accepts ":" instead of "/" for file and folder separator.

The GDB console output can be captured by setting the GDB option to write it to file. this is done by typing the following command in Terminal:

defaults write com.apple.Xcode PBXGDBDebuggerLogToFile YES 
defaults write com.apple.Xcode PBXGDBDebuggerLogFileName <path to my gdb output file>

Lastly, many thanks to various ppl who have helped to solve this problem.

chuan
A: 

Check out UISpec http://code.google.com/p/uispec/

It's a full automation test framework being developed for the iphone.

Brian
A: 

xcodebuild will just build the binary and it will not upload the newly compiled binary to iphone.

actually it can upload (after signing it), but not run too bad... maybe it can be run using gdb once connected to target but how (ip?, usb? usbnet?) ?

Regards

rzr
+1  A: 

Check out iphone_testify, it works well with OCUnit and Google Toolbox For Mac, and I think it could be possible extend it for something like UISpec.

Regards

Giordano Scalzo
A: 

Hi,

I'm also trying to do auto-testing for iPhone. Using AppleScript, I'm now able, thanks to this post, to compile, execute & run an app on device. Now I would like to get the data of the application but without using the XCode Organizer. Where you able to do it?

Niko

Niko
Hi Niko, without XCode you cannot get the internal state of the program in debug mode. Unless you can engineer in a test instrument i.e., sending you the data of the application, then nothing much you can do about it.
chuan
Thanks Chuan. I'll find another way to extract my data then.
Niko