Friday October 26, 2012

✦ Stress Testing And Hands-Free Screenshots With UI Automation

Looking for more information about UI Automation? Check out my new book, published through the Pragmatic Programmers. Thanks for your support!

First announced at CocoaConf Portland 2012, I’m pleased to release UI AutoMonkey and UI Screen Shooter, two new open source projects for iOS developers using the UI Automation instrument.

UI AutoMonkey

UI AutoMonkey is a simple to set up stress testing tool for iOS applications. You can pound on your app until it wilts with a barrage of taps, swipes, device rotations, and even locking and unlocking the home screen! Watch the app’s performance characteristics with Instruments, discover race conditions, or just enjoy watching your work under butt dialing conditions.

You don’t need to install anything to make this work. You can simply paste the script into UI Automation when using Instruments. Of course, you can use this from the command line if you already have a workflow set up, but there’s no need to go through all that. It’s plug and play.

Configuration happens at the top of the script. Adjust the probability values to taste. Here’s the defaults:

config: {
  numberOfEvents: 1000,
  delayBetweenEvents: 0.05,    // In seconds

  // Events are triggered based on the relative weights here.
  // The event with this highest number gets triggered the most.
  eventWeights: {
    tap: 30,
    drag: 1,
    flick: 1,
    orientation: 1,
    clickVolumeUp: 1,
    clickVolumeDown: 1,
    lock: 1

Check out the readme for more info.

UI Screen Shooter

UI Screen Shooter is a demonstration of using UI Automation and some shell scripting magic to take screen shots of your iOS app. You know you need it. :)

This saves quite a bit of time since we need to generate screens for the 3.5” display, the 4” display, and both iPhone and iPad if your app is universal–not to mention that you have to do this for every localization you support in the store.

Here’s a video of the scripts running againts my app, ReadMore.

This is a little more complicated to use than UI AutoMonkey, it’s not just plug and play. But I’ve documented all the scripts heavily. Check out the readme to see where to start following the execution path. Trust me, this is a real time saver.

Both are licensed under the liberal MIT license. Feel free to send me feedback or pull requests to make these better. For the win!