cedar
TRANSCRIPT
CedarTesting in iOS
Jeff Hui
Why Test?
Why Test?
•Catch regressions
Why Test?
•Catch regressions
•Better design
Why Test?
•Catch regressions
•Better design
•Refactor more confidently
Why Cedar?
Why Cedar?
•Cross-platform
Why Cedar?
•Cross-platform
•Fast
Why Cedar?
•Cross-platform
•Fast
•Elegant DSL
describe(@”bowler”, ^{ beforeEach(^{ // do stuff });
describe(@”-score”, ^{ context(@”when having a perfect game”, ^{ it(@”should return a perfect score”, ^{ }); }); });});
value should equal(@”someString”);
value should equal(5);
id runLoop = nice_fake_for([NSRunLoop class]);// do stuffNSTimer *expectedTimer = ....;runLoop should have_received(@selector(addTimer:forMode:)).with(expectedTimer, NSDefaultRunLoopMode);
Fakes/Doubles
spy_on(controller.textField);[controller.textField becomeFirstResponder];controller.textField should have_received(@selector(becomeFirstResponder));
Spies
sharedExamplesFor(@”showing an alert”, ^(NSDictionary*context){ it(@”shows an alert”, ^{...});});
describe(@”tapping the submit button”, ^{ itShouldBehaveLike(@”showing an alert”);});
describe(@”tapping another”, ^{ itShouldBehaveLike(@”showing an alert”);});
Shared Examples
• Cedar (github.com/pivotal/cedar)
• PivotalCoreKit (github.com/pivotal/pivotalcorekit)
• CedarShortcuts (github.com/cppforlife/CedarShortcuts)
• BetterConsole (github.com/cppforlife/BetterConsole)