SlideShare a Scribd company logo
BDD for iOS
by JMac
What is BDD?
“Behavior Driven Development”
Why BDD?
“Because we want to the way our system behaves,
not how it is implemented.”
–J.B. Rainsberger
“Integration tests are a scam.”
Sales Demo
How do I practice BDD for iOS?
“Cedar”
What is Cedar?
“a BDD-style Objective-C testing framework
with matchers and test doubles.”
How do I install Cedar?
“With CocoaPods”
What is CocoaPods?
“CocoaPods is a dependency manager for Swift
and Objective-C Cocoa projects, which automates
and simplifies the process of using 3rd-party
libraries in your projects.”
How do I use CocoaPods?
gem install cocoapods
pod init
The Podfile
platform :ios, '8.1'
target 'parked' do
pod 'Blindside'
pod 'Flurry-iOS-SDK'
end
target 'Specs' do
pod 'Blindside'
pod 'Cedar', git: 'https://github.com/pivotal/cedar.git'
pod 'PivotalCoreKit/Development', :git => 'https://github.com/
pivotal/PivotalCoreKit.git'
end
Project Type
Minimum SDK
Targets
Package/Pod
How do I install/update the pods?
pod install
Is that it?
“No.”
A few gotchas…
❖ You’ll want to close Xcode while managing Pods
❖ You’ll need to create any additional targets referenced in
the Podfile
❖ Once you install Pods, you need to open the Xcode
workspace
Setup Demo
The anatomy of a Spec file
❖ describe
❖ it
❖ beforeEach
❖ context
❖ and more (but not today)
describe
// group specs together
describe(@"the thing your testing", ^{
// test goes here code
});
it
// the test, expectation, or "spec"
it(@"should do the thing", ^{
expected should equal(actual);
});
beforeEach
// runs before each spec in the current block
beforeEach(^{
subject = [SomeViewController alloc]
init];
});
context
// group specs together based on state
context(@"when user is logged in", ^{
// test code
});
context(@"when user is logged out", ^{
// test code
});
Full Example
describe(@"tapping the save button", ^{
context(@"when the fields have input", ^{
it(@"should store the input in the database", ^{
// example
});
it(@"should call the delegate", ^{
// example
});
});
context(@"when the fields do not have input", ^{
it(@"should show an alert", ^{
// example
});
});
});
Matchers
❖ should and should_not
❖ equal
❖ be_nil, be_truthy, be_falsy, be_empty
❖ be_greater_than, be_less_than, etc
❖ be_same_instance_as, be_instance_of
Example
person.name should equal(@"JMac");
person.name should_not be_nil;
person.name.length should be_less_than(@5);
person should be_instance_of([Person class]);
person should be_same_instance_as(person);
Test Doubles (fakes)
❖ fake_for creates a test double of an object so its
methods can be stubbed
❖ nice_fake_for creates a test double of an object with
all its methods stubbed to return nil
Example
fakePerson = fake_for([Person class]);
fakePerson.name; // exception
niceFakePerson = nice_fake_for([Person class]);
niceFakePerson.name; // nil
niceFakePerson stub_method(@selector(name))
.and_return(@"JMac");
niceFakePerson.name; // @"JMac"
Code Demo
Resources
❖ CocoaPods
❖ Cedar
❖ Blindside
❖ Thrust
❖ Follow me on Twitter: @gonedark

More Related Content

What's hot

Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
Andrei Savu
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard Introduction
Anthony Chen
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
Remo Jansen
 
Let's Redux!
Let's Redux!Let's Redux!
Let's Redux!
Joseph Chiang
 
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Chris Gillum
 
Extending Kubernetes with Operators
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operators
peychevi
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
Imran Sayed
 
ATG Advanced RQL
ATG Advanced RQLATG Advanced RQL
ATG Advanced RQL
Kate Semizhon
 
Protecting your data from SQL Injection attacks
Protecting your data from SQL Injection attacksProtecting your data from SQL Injection attacks
Protecting your data from SQL Injection attacks
Kevin Alcock
 
Scala, XML and GAE
Scala, XML and GAEScala, XML and GAE
Scala, XML and GAE
markryall
 
ProvJS: Six Months of ReactJS and Redux
ProvJS:  Six Months of ReactJS and ReduxProvJS:  Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
Thom Nichols
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
Stephan Schmidt
 
Cocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollersCocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollers
Stijn Willems
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
Fernando Daciuk
 
Backbone js
Backbone jsBackbone js
Backbone js
Knoldus Inc.
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
FITC
 
Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scala
Sandeep Purohit
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2
Gil Fink
 
iOS testing
iOS testingiOS testing
iOS testing
Tomasz Janeczko
 

What's hot (20)

Simple REST with Dropwizard
Simple REST with DropwizardSimple REST with Dropwizard
Simple REST with Dropwizard
 
Dropwizard Introduction
Dropwizard IntroductionDropwizard Introduction
Dropwizard Introduction
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
Let's Redux!
Let's Redux!Let's Redux!
Let's Redux!
 
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
Advanced Durable Functions - Serverless Meetup Tokyo - Feb 2018
 
Extending Kubernetes with Operators
Extending Kubernetes with OperatorsExtending Kubernetes with Operators
Extending Kubernetes with Operators
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
 
ATG Advanced RQL
ATG Advanced RQLATG Advanced RQL
ATG Advanced RQL
 
Protecting your data from SQL Injection attacks
Protecting your data from SQL Injection attacksProtecting your data from SQL Injection attacks
Protecting your data from SQL Injection attacks
 
Scala, XML and GAE
Scala, XML and GAEScala, XML and GAE
Scala, XML and GAE
 
Api workshop
Api workshopApi workshop
Api workshop
 
ProvJS: Six Months of ReactJS and Redux
ProvJS:  Six Months of ReactJS and ReduxProvJS:  Six Months of ReactJS and Redux
ProvJS: Six Months of ReactJS and Redux
 
State Models for React with Redux
State Models for React with ReduxState Models for React with Redux
State Models for React with Redux
 
Cocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollersCocoa heads testing and viewcontrollers
Cocoa heads testing and viewcontrollers
 
Designing applications with Redux
Designing applications with ReduxDesigning applications with Redux
Designing applications with Redux
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Building React Applications with Redux
Building React Applications with ReduxBuilding React Applications with Redux
Building React Applications with Redux
 
Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scala
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2
 
iOS testing
iOS testingiOS testing
iOS testing
 

Viewers also liked

Локализация программных продуктов и тестирование локализации
Локализация программных продуктов и тестирование локализацииЛокализация программных продуктов и тестирование локализации
Локализация программных продуктов и тестирование локализации
SQALab
 
Quick 入門 | iOS RDD テストフレームワーク for Swift/Objective-C
Quick 入門 | iOS RDD テストフレームワーク for Swift/Objective-CQuick 入門 | iOS RDD テストフレームワーク for Swift/Objective-C
Quick 入門 | iOS RDD テストフレームワーク for Swift/Objective-C
Yuki Tanabe
 
Bdd for ios with kiwi
Bdd for ios with kiwiBdd for ios with kiwi
Bdd for ios with kiwiGnat
 
iOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentiOS Behavior-Driven Development
iOS Behavior-Driven Development
Brian Gesiak
 
iOS UI Testing with Frank
iOS UI Testing with FrankiOS UI Testing with Frank
iOS UI Testing with FrankKeith Pitt
 

Viewers also liked (6)

Локализация программных продуктов и тестирование локализации
Локализация программных продуктов и тестирование локализацииЛокализация программных продуктов и тестирование локализации
Локализация программных продуктов и тестирование локализации
 
Quick 入門 | iOS RDD テストフレームワーク for Swift/Objective-C
Quick 入門 | iOS RDD テストフレームワーク for Swift/Objective-CQuick 入門 | iOS RDD テストフレームワーク for Swift/Objective-C
Quick 入門 | iOS RDD テストフレームワーク for Swift/Objective-C
 
Bdd for ios with kiwi
Bdd for ios with kiwiBdd for ios with kiwi
Bdd for ios with kiwi
 
I os tdd-with-bdd
I os tdd-with-bddI os tdd-with-bdd
I os tdd-with-bdd
 
iOS Behavior-Driven Development
iOS Behavior-Driven DevelopmentiOS Behavior-Driven Development
iOS Behavior-Driven Development
 
iOS UI Testing with Frank
iOS UI Testing with FrankiOS UI Testing with Frank
iOS UI Testing with Frank
 

Similar to BDD in iOS with Cedar

Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
Tobias Trelle
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
Alive Kuo
 
Compass Framework
Compass FrameworkCompass Framework
Compass Framework
Lukas Vlcek
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
Igor Bronovskyy
 
Scale Your Data Tier With Windows Server App Fabric
Scale Your Data Tier With Windows Server App FabricScale Your Data Tier With Windows Server App Fabric
Scale Your Data Tier With Windows Server App Fabric
Chris Dufour
 
Revolution or Evolution in Page Object
Revolution or Evolution in Page ObjectRevolution or Evolution in Page Object
Revolution or Evolution in Page Object
Artem Sokovets
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
Gil Fink
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
Gil Fink
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
Siarzh Miadzvedzeu
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
Manish Pandit
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
John Quaglia
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
John Brunswick
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
JAX London
 
How do I write testable javascript?
How do I write testable javascript?How do I write testable javascript?
How do I write testable javascript?
devObjective
 
How do I write Testable Javascript?
How do I write Testable Javascript?How do I write Testable Javascript?
How do I write Testable Javascript?
Gavin Pickin
 

Similar to BDD in iOS with Cedar (20)

Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Compass Framework
Compass FrameworkCompass Framework
Compass Framework
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Scale Your Data Tier With Windows Server App Fabric
Scale Your Data Tier With Windows Server App FabricScale Your Data Tier With Windows Server App Fabric
Scale Your Data Tier With Windows Server App Fabric
 
Revolution or Evolution in Page Object
Revolution or Evolution in Page ObjectRevolution or Evolution in Page Object
Revolution or Evolution in Page Object
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Quick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using JasmineQuick Tour to Front-End Unit Testing Using Jasmine
Quick Tour to Front-End Unit Testing Using Jasmine
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
 
How do I write testable javascript?
How do I write testable javascript?How do I write testable javascript?
How do I write testable javascript?
 
How do I write Testable Javascript?
How do I write Testable Javascript?How do I write Testable Javascript?
How do I write Testable Javascript?
 

More from Jason McCreary

Git Empowered
Git EmpoweredGit Empowered
Git Empowered
Jason McCreary
 
Hack the Future
Hack the FutureHack the Future
Hack the Future
Jason McCreary
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1
Jason McCreary
 
Patterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic ProgrammerPatterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic Programmer
Jason McCreary
 
Cache, Workers, and Queues
Cache, Workers, and QueuesCache, Workers, and Queues
Cache, Workers, and Queues
Jason McCreary
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
Jason McCreary
 
21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast
Jason McCreary
 
21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast
Jason McCreary
 
Configuring WordPress for Multiple Environments
Configuring WordPress for Multiple EnvironmentsConfiguring WordPress for Multiple Environments
Configuring WordPress for Multiple Environments
Jason McCreary
 

More from Jason McCreary (9)

Git Empowered
Git EmpoweredGit Empowered
Git Empowered
 
Hack the Future
Hack the FutureHack the Future
Hack the Future
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1
 
Patterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic ProgrammerPatterns, Code Smells, and The Pragmattic Programmer
Patterns, Code Smells, and The Pragmattic Programmer
 
Cache, Workers, and Queues
Cache, Workers, and QueuesCache, Workers, and Queues
Cache, Workers, and Queues
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
 
21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast
 
21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast
 
Configuring WordPress for Multiple Environments
Configuring WordPress for Multiple EnvironmentsConfiguring WordPress for Multiple Environments
Configuring WordPress for Multiple Environments
 

BDD in iOS with Cedar