Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
iOS Unit Testing
Search
Marcilio Junior
September 03, 2016
Programming
0
60
iOS Unit Testing
Digital Day BH 2016
Github:
https://github.com/marciliojrs/DigitalDayBH2016
Marcilio Junior
September 03, 2016
Tweet
Share
More Decks by Marcilio Junior
See All by Marcilio Junior
Making Sourcery write code for you
marciliojrs
0
72
Sorcery with Sourcery
marciliojrs
0
40
Ferramentas Indispensáveis no Desenvolvimento iOS
marciliojrs
1
120
Other Decks in Programming
See All in Programming
Ruby Parser progress report 2025
yui_knk
1
440
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.3k
Rancher と Terraform
fufuhu
2
400
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
240
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
1.3k
個人軟體時代
ethanhuang13
0
320
Design Foundational Data Engineering Observability
sucitw
3
190
RDoc meets YARD
okuramasafumi
4
170
知っているようで知らない"rails new"の世界 / The World of "rails new" You Think You Know but Don't
luccafort
PRO
1
110
Improving my own Ruby thereafter
sisshiki1969
1
160
print("Hello, World")
eddie
2
530
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
520
Embracing the Ebb and Flow
colly
87
4.8k
Designing for Performance
lara
610
69k
Thoughts on Productivity
jonyablonski
70
4.8k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
A designer walks into a library…
pauljervisheath
207
24k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Art of Programming - Codeland 2020
erikaheidi
56
13k
Being A Developer After 40
akosma
90
590k
Faster Mobile Websites
deanohume
309
31k
Producing Creativity
orderedlist
PRO
347
40k
Transcript
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
iOS
unit Testing
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
who
am i iOS Lead @ HE:labs iOS Instructor @ Framework Training Center Professor @ PUC Minas CocoaHeads BH Co-organizer Marcílio Júnior
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
unit
Testing WHY?
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
Why
test • Avoid break your codebase • It’s a way to document your code • Make development faster • Reduce your fear • Improve your code quality
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
what
to test • If possible, everything
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
TYPEs
of unit tests
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
unit
test types • Mathematical • Pure functions • Delegation • Output
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
unit
test types • Mathematical • Delegation • Propagation • Output
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
unit
test types • Mathematical • Delegation • Output • More than one input/output
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
(B/T)DD
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
(B/T)DD
• Test-Driven Development • Behaviour-Driven Development
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
(B/T)DD
• Test-Driven Development • Behaviour-Driven Development let counter = Counter() let expectedCount = 1 counter.tick() XCTAssertEqual(counter.count, expectedCount)
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
(B/T)DD
• Test-Driven Development • Behaviour-Driven Development describe("Counter") { var counter: Counter! beforeEach { counter = Counter() } it("should increase count by 1 after calling tick") { let expectedCount = counter.count + 1 counter.tick() expect(counter.count).to(be(expectedCount)) } }
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
TESTING
frameworks • XCTest • Quick
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
TESTING
frameworks • XCTest • default testing framework of Xcode • Quick
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
TESTING
frameworks • XCTest • Quick • BDD testing framework
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
quick
• https://github.com/Quick/Quick • Inspired by RSpec, Specta e Ginkgo • Swift & Objective-C support • It comes with a great matcher framework: Nimble
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
quick
• BDD DSL • describe • context • it • beforeEach • afterEach
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
testable
imports • @testable import • allows use your internal classes in unit test target • don’t need to set the unit test target to all your classes
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
live
coding
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
one
more thing...
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
tips
• Dependency injection • Testable architectures • Mocks & Stubs • Code Coverage
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
QUestions?
DIGITAL DAY - SEP 3, 2016 MARCÍLIO JÚNIOR
[email protected]
thanks!
@marciliojrs /in/marciliojunior
[email protected]
@marcilio iOSDevBR @marciliojrs