Skip to content

Instantly share code, notes, and snippets.

@ecgreb
Last active December 17, 2015 03:19
Show Gist options
  • Save ecgreb/5542148 to your computer and use it in GitHub Desktop.
Save ecgreb/5542148 to your computer and use it in GitHub Desktop.
@implementation KIFTestStep (HelloTDDAdditions)
+ (id)stepToVerifyGreeting:(NSString *)expectedLabel {
NSString *description =
[NSString stringWithFormat:@"Verify output is '%@'",
expectedLabel];
return [self stepWithDescription:description
executionBlock:^(KIFTestStep *step, NSError **error) {
UIAccessibilityElement *element =
[[UIApplication sharedApplication]
accessibilityElementWithLabel:@"Greeting"];
UILabel *label = (UILabel *)[UIAccessibilityElement
viewContainingAccessibilityElement:element];
if ([expectedLabel isEqualToString:label.text]) {
return KIFTestStepResultSuccess;
}
KIFTestCondition(NO, error,
@"Failed to compare the label text: expected '%@', actual '%@'",
expectedLabel, label.text);
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment