http://code.google.com/p/uispec/wiki/Installation

UISpec is a Behavior Driven Development framework for the iPhone that provides a full automated testing solution that drives the actual iPhone UI. It is modeled after the very popular RSpec for Ruby.
To make finding specific views in the iPhone UI easy, UISpec includes a very powerful view traversal DSL called UIQuery. Not only can you easily traverse the view heirarchy, you can also interact with the views you find.

Example Spec

The following is just a taste of what's possible with UISpec:

#import "DescribeEmployeeAdmin.h"
#import "SpecHelper.h"

@implementation DescribeEmployeeAdmin

-(void)before {
        //login as default admin before each example
        [SpecHelper loginAsAdmin];
}

-(void)after {
        //logout after each example
        [SpecHelper logout];
}

-(void)itShouldHaveDefaultUsers {
        //Check that all default users are in list
        [[app.tableView.label text:@"Larry Stooge"] should].exist;
        [[app.tableView.label text:@"Curly Stooge"] should].exist;
        [[app.tableView.label text:@"Moe Stooge"] should].exist;
}

-(void)itShouldAddAUser {
        //Click the + button
        [app.navigationButton touch];
       
        //Set the form fields.
        //Also ".with" is optional so we here we can show the different syntax
        [[app.textField.with placeholder:@"First Name"] setText:@"Brian"];
        [[app.textField.with placeholder:@"Last Name"] setText:@"Knorr"];
        [[app.textField.with placeholder:@"Email"] setText:@"b@g.com"];
        [[app.textField placeholder:@"Username"] setText:@"bkuser"];
        [[app.textField placeholder:@"Password"] setText:@"test"];
        [[app.textField placeholder:@"Confirm"] setText:@"test"];
       
        //Click the Save button
        [[app.navigationButton.label text:@"Save"] touch];
       
        //Make sure the error alert view doesn't appear
        [app timeout:1].alertView.should.not.exist;
       
        //User list should now have a new entry
        [[app.tableView.label text:@"Brian Knorr"] should].exist;
}

@end
Share