Fog Creek Software
g
Discussion Board




Automated UI Testing under Mac OS X

has anybody done AppleScript based automated UI testing for a cocoa or carbon application.
what are your experiences with that?

is it too complicated to consider for a small or medium sized project considering the time it takes and saves?

I have looked at OCUnit Testing Framework which seemed good for Frameworks and Non-UI functionality testing,
but for UI testing, it does not look promising.

cocoa developer for mac
Monday, April 5, 2004

Try asking at a Mac forum there is a General Programming board at idevgames.com.

Not Many Maccers here
Monday, April 5, 2004

You might also consider asking on the Cocoa-dev mailing list hosted by Apple or the MacOSX-dev list hosted by OmniGroup.

I haven't run across any tools like WinRunner for Mac OS X; but I'd be surprised if solutions don't already exist.

Jeff Watkins
Monday, April 5, 2004

"has anybody done AppleScript based automated UI testing for a cocoa or carbon application.
what are your experiences with that?"

May be non-AppleScript/Apple event-driven solutions, but couldn't tell you about those. If you do it via application scripting, the AppleScript Implementors list should be a good place to ask: http://www.lists.apple.com/mailman/listinfo/applescript-implementors

One problem with AppleScript (In My Heavily Biased Opinion) is its almost total lack of libraries. Anything you need you usually have to write for yourself. Perl + Mac::Glue [1] or MacPython + appscript [2] might be better alternatives; much better languages with excellent libraries, tools and community support. e.g. Here's a basic example of UI scripting from MacPython via appscript [my puppy]:

#######

#!/usr/local/bin/pythonw

from appscript import *

teGUI = app('System Events.app').processes['TextEdit']
app('TextEdit.app').activate()

teMenus = teGUI.menu_bars[1].menus
teMenus['File'].menu_items['New'].click()
teMenus['Edit'].menu_items['Paste'].click()
teMenus['Window'].menu_items['Zoom Window'].click()

#######

[1] http://search.cpan.org/~cnandor/
[2] http://freespace.virgin.net/hamish.sanderson/

has
Monday, April 5, 2004

You'd be surprised just how far you can get with OCUnit.

I regularly load nib files from unit tests, use key-value coding to get what's bound to attributes, use -performClick: to make buttons send their action to their target (or the responder chain if they're in it), and so on.

I use this to do test-driven development of Mac user interfaces.  About the only thing I'm unable to do right now is "poke" a value into a control and have the control propagate the value via its bindings.  But anything beyond Cocoa Bindings should just work straight from Objective-C; you don't need to display windows on screen or anything like that to put them under test.

  -- Chris Hanson http://www.livejournal.com/users/chanson/

Chris Hanson
Monday, April 5, 2004

"I regularly load nib files from unit tests, use key-value coding to get what's bound to attributes, use -performClick: to make buttons send their action to their target (or the responder chain if they're in it), and so on."

F-Script <http://www.fscript.org/> sounds like it might be good for this too: "F-Script is a lightweight object-oriented scripting layer specifically designed for the Mac OS X object system (i.e. Cocoa). F-Script provides scripting and interactive access to Cocoa frameworks and custom Objective-C objects."

has
Tuesday, April 6, 2004

*  Recent Topics

*  Fog Creek Home