cedar

16
Cedar Testing in iOS Jeff Hui

Upload: apartment-list

Post on 23-Jun-2015

98 views

Category:

Business


2 download

TRANSCRIPT

Page 1: Cedar

CedarTesting in iOS

Jeff Hui

Page 2: Cedar

Why Test?

Page 3: Cedar

Why Test?

•Catch regressions

Page 4: Cedar

Why Test?

•Catch regressions

•Better design

Page 5: Cedar

Why Test?

•Catch regressions

•Better design

•Refactor more confidently

Page 6: Cedar

Why Cedar?

Page 7: Cedar

Why Cedar?

•Cross-platform

Page 8: Cedar

Why Cedar?

•Cross-platform

•Fast

Page 9: Cedar

Why Cedar?

•Cross-platform

•Fast

•Elegant DSL

Page 10: Cedar

describe(@”bowler”, ^{ beforeEach(^{ // do stuff });

describe(@”-score”, ^{ context(@”when having a perfect game”, ^{ it(@”should return a perfect score”, ^{ }); }); });});

Page 11: Cedar

value should equal(@”someString”);

Page 12: Cedar

value should equal(5);

Page 13: Cedar

id runLoop = nice_fake_for([NSRunLoop class]);// do stuffNSTimer *expectedTimer = ....;runLoop should have_received(@selector(addTimer:forMode:)).with(expectedTimer, NSDefaultRunLoopMode);

Fakes/Doubles

Page 14: Cedar

spy_on(controller.textField);[controller.textField becomeFirstResponder];controller.textField should have_received(@selector(becomeFirstResponder));

Spies

Page 15: Cedar

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

Page 16: Cedar

• Cedar (github.com/pivotal/cedar)

• PivotalCoreKit (github.com/pivotal/pivotalcorekit)

• CedarShortcuts (github.com/cppforlife/CedarShortcuts)

• BetterConsole (github.com/cppforlife/BetterConsole)