My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
                
People details
Project owners:
  btknorr
Project committers:
blakewatters, Cory.M.Smith, pezlists

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.

If you have any questions or issues please post them in the UISpec Group.

Installation

Documentation


Recent News!

Simple scripting language support added to UISpec called UIScript. It allows you to send a string as a script and have it run dynamically. Here is an example of using UIScript to automate a login screen on the iphone:

$(@"textField with placeholder:'Username' setText:'bkuser'");
$(@"textField with placeholder:'Password' setText:'bkpassword'");
$(@"navigationButton label with text:'Login' touch");

This really open up the possibility of using UISpec from other languages like Ruby or Java, or even the ability to have an interactive console that drives the iphone ui. Check it out here.


Demo

Thanks Patrick Hüsler for the video!

Included in the distribution is the UISpecDemo XCode project that shows UISpec running against the Employee Admin application from the Objective-C port of PureMVC. The Spec is defined in DescribeEmployeeAdmin.m and contains 5 examples.

To run the demo:

And if you have any issues please post them in the UISpec Group.


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








Hosted by Google Code