I made this presentation at BlackBerry DevCon 2010 just a few days ago. Capturing some of the key points here.

This technique creates uses Python to automate native mobile applications using simulator libraries (also written in Python). How this works -

  • Build a simulator library such as bblib.py, androidlib.py, iphonelib.py. The former two will soon be available in the open source community (likely github)
This library should contain the means for you to communicate with the simulator as well as useful commands such as capturing screenshots, installing your app.
  • Create your application interface class that is applicable across your mobile platforms.
E.g. AddressBook application would have addContact, findContact, updateContact interface methods.
  • Implement the interface class using the simulator library. 
def addContact(self, contact): 
    # Touch screen at 100, 50 to create new contact 
    touch(100, 50)
    enter(contact.getFirstname())
    thumbwheel('down', 1)
    enter(contact.getLastname())
    # To save 
   menu()
   touch(50, 300)
  • Write your tests with these interface methods. This way your tests can be run on different devices of the same platform and even on different mobile platforms.
class AddContactTest(unittest.TestCase):
    # Magic line to get the device to execute
    device = testenv.getDevice()
    def addContactWithOnlyFirstname(self):
        self.contact.setFirstname(firstname)
        self.device.add(self.contact)
  • Run your tests in Hudson.