Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode Test Automation For IPhone

Tags:

iphone

testing

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.

like image 653
chuan Avatar asked Jun 15 '09 10:06

chuan


People also ask

What does Xcode provide for mobile automation?

It enables developers and testers to perform automated and manual testing of mobile apps and websites on real devices.

What is automation test iOS?

iOS Automation Testing using Xcode Test-Driven Development (TDD) is a Testing model which is applied to iOS application testing. In this model, a tester has to follow 4 phases below: Design: Figure out what you want to test, design your test cases. Test: Run all tests and see if test cases fail.

What is UI Automation Iphone?

UI Automation is a tool that Apple provides and maintains for higher level, automated, testing of iOS applications. Tests are written in JavaScript, adhering to an API defined by Apple. Writing tests can be made easier by relying on accessibility labels for user interface elements in your application.

How do I run a UI test in Xcode?

When you're ready to test, go to a test class and place the cursor inside the test method to record the interaction. From the debug bar, click the Record UI Test button. Xcode will launch the app and run it. You can interact with the element on-screen and perform a sequence of interactions for any UI test.


1 Answers

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.

like image 60
chuan Avatar answered Sep 28 '22 02:09

chuan