Last active
August 29, 2015 14:02
-
-
Save wearhere/76f6d26015325ecc9e5b to your computer and use it in GitHub Desktop.
Examining table view cells using Subliminal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Subliminal/Subliminal.h> | |
@interface TableViewCellTest : SLTest | |
@end | |
@implementation TableViewCellTest | |
- (void)setUpTest { | |
[super setUpTest]; | |
// navigate to the table view | |
} | |
- (void)testTableLayout { | |
SLAssertTrue(SLAskApp(numberOfRows) == 1, @"There should be only one row."); | |
SLAssertTrue([SLAskApp1(labelOfRowAtIndex:, @1) isEqualToString:@"Foo"], @"The first and only cell should say 'Foo'."); | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if INTEGRATION_TESTING | |
#import <Subliminal/Subliminal.h> | |
#endif | |
@interface TableViewController : UITableViewController | |
@end | |
@implementation TableViewController | |
- (instancetype)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle { | |
self = [super initWithNibName:nibName bundle:bundle]; | |
if (self) { | |
#if INTEGRATION_TESTING | |
[[SLTestController sharedTestController] registerTarget:self forAction:@selector(numberOfRows)]; | |
[[SLTestController sharedTestController] registerTarget:self forAction:@selector(labelOfRowAtIndex:)]; | |
#endif | |
} | |
return self; | |
} | |
- (void)dealloc { | |
#if INTEGRATION_TESTING | |
[[SLTestController sharedTestController] deregisterTarget:self]; | |
#endif | |
} | |
- (NSNumber *)numberOfRows { | |
// assumes that there's only one section | |
return @([self tableView:self.tableView numberOfRowsInSection:0]); | |
} | |
- (NSString *)labelOfRowAtIndex:(NSNumber *)index { | |
NSIndexPath *rowPath = [NSIndexPath indexPathForRow:[index unsignedIntegerValue] inSection:0]; | |
UITableViewCell *cellAtRow = [self tableView:self.tableView cellForRowAtIndexPath:rowPath]; | |
return cellAtRow.textLabel.text; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment