Skip to content

Instantly share code, notes, and snippets.

@akisute
Created January 23, 2012 12:36
Show Gist options
  • Save akisute/1662887 to your computer and use it in GitHub Desktop.
Save akisute/1662887 to your computer and use it in GitHub Desktop.
Investigating with UIKit objects are available in "Logic Tests" of the SenTestingKit
- (void)testUIKit
{
// In this SenTestKit unit testing target, we can't use specific UI-related classes and objects
// Usualy, <UIKit/UIKit.h> is not even imported in templates created by Xcode
STAssertNil([UIApplication sharedApplication], @"UIApplication is not available");
STAssertNotNil([UIDevice currentDevice], @"UIDevice is still available");
STAssertNotNil([UIScreen mainScreen], @"UIScreen is still available, but not sure it returns correct screen sizes");
STAssertNotNil([UIColor clearColor], @"UIColor is still available");
//STAssertNotNil([UIFont systemFontOfSize:[UIFont systemFontSize]], @"UIFont is still available, but the test case is halted on this line. You should not use UIFont in the unit test.");
STAssertTrue([[[NSBundle mainBundle] resourcePath] rangeOfString:@"Platforms/iPhoneSimulator.platform"].location != NSNotFound, @"NSBundle is still available, but the bundle resource location (%@) is NOT the application bundle resource location which usually contains resource files. Thus basically we can't use NSBundle in unit tests.", [[NSBundle mainBundle] resourcePath]);
STAssertNil([UIImage imageNamed:@"SampleImage.png"], @"UIImage is not available (at least with imageNamed: method) because of the NSBundle problem shown above.");
// Not sure whether UIImage is available through imageWithData:, imageWithContentOfFile: or imageWithCGImage:
// TODO: UIDocument, UIManagedDocument
// TODO: UINib
// TODO: UIPrint related classes
// TODO: UIPasteboard
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment