FoneMonkey

Whenever you save a script from the FoneMonkey console, three files are created:

  • Native FoneMonkey script file - A Cocoa Property List XML file called YourScriptName.fm that can be open and run with the FoneMonkey console.
  • OCUnit source file - An Objective-C source file called YourScriptName.m that can be executed with an OCUnit runner. You can extend the generated code with Objective-C logic to do things like looping, conditional branching, or data-driving of your tests.
  • QUnit source file – A JavaScript source file called YourScriptName.js that can be executed by setting FM_ENABLE_QUNIT environment variable with the value: YourScriptName.js – As with the OCUnit source file, you can extend the generated code with JavaScript logic.
  • UIAutomation source file (DEPRECATED in FoneMonkey 5.2a – Set the FM_ENABLE_UIAUTOMATION environment variable to generate this source file instead of the QUnit source file) - A generated JavaScript source file called YourScriptName.js that can be executed with Apple's Automation Instrument. As with OCUnit tests, UIAutomation tests can be customized and extended with additional control or data-driven logic. Executing FoneMonkey's generated UIAutomation scripts does not require linking any of the FoneMonkey or OCUnit libraries into your iOS app, so UIAutomation scripts can be run directly against applications built for release.

In addition to the three script files, FoneMonkey also copies the FoneMonkey UIAutomation support library, FoneMonkey.js to your documents directory. This file is required for running generated UIAutomation scripts.

Please note that the FoneMonkey console can only read and run native FoneMonkey (.fm) files. Any changes you make to generated (.m or .js) source files are invisible to the FoneMonkey console. You can however modify the .fm file directly with a text, xml, or property list editor, and then open and run the resulting script in the FoneMonkey console.

The three scripts are saved under your application's Documents directory.

The names and locations of the files being written when you save a script are displayed in the XCode console, for example:

2011-02-03 19:22:42.611 FoneMonkeyTestApp[35019:207] saving script "sampletest" to /Users/sstern/Library/Application Support/iPhone Simulator/4.2/Applications/C8875700-37D8-47C2-ABFC-B01B7CF3DE2C/Documents
2011-02-03 19:22:42.612 FoneMonkeyTestApp[35019:207] Writing /Users/sstern/Library/Application Support/iPhone Simulator/4.2/Applications/C8875700-37D8-47C2-ABFC-B01B7CF3DE2C/Documents/FoneMonkey.js
2011-02-03 19:22:42.614 FoneMonkeyTestApp[35019:207] Writing /Users/sstern/Library/Application Support/iPhone Simulator/4.2/Applications/C8875700-37D8-47C2-ABFC-B01B7CF3DE2C/Documents/sampletest.js
2011-02-03 19:22:42.616 FoneMonkeyTestApp[35019:207] Writing /Users/sstern/Library/Application Support/iPhone Simulator/4.2/Applications/C8875700-37D8-47C2-ABFC-B01B7CF3DE2C/Documents/sampletest.m

 

Although the Property List XML files can be easily edited by hand in any text or XML editor, it is not possible to specify anything but sequential logic in this format. If you need to create more complex testing flows or read data from a file or database to drive your test scripts, you need to extend your scripts by editing the generated Objective-C or JavaScript source files.

Script Language File Runner Can be data-driven or extended with control logic Requires FoneMonkey Libraries for Execution
XML YourScriptName.fm Console No Yes
Objective-C YourScriptName.m OCUnit Yes

Yes

JavaScript  YourScriptName.js  QUnit Yes Yes
JavaScript DEPRECATED  YourScriptName.js  Instruments Yes No