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
速いWebフレームワークを作る
yusukebe
5
1.7k
rage against annotate_predecessor
junk0612
0
170
為你自己學 Python - 冷知識篇
eddie
1
350
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
300
Android端末で実現するオンデバイスLLM 2025
masayukisuda
1
150
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
390
🔨 小さなビルドシステムを作る
momeemt
4
680
意外と簡単!?フロントエンドでパスキー認証を実現する WebAuthn
teamlab
PRO
2
740
Performance for Conversion! 分散トレーシングでボトルネックを 特定せよ
inetand
0
140
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
1.3k
Flutter with Dart MCP: All You Need - 박제창 2025 I/O Extended Busan
itsmedreamwalker
0
150
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
290
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
188
55k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Into the Great Unknown - MozCon
thekraken
40
2k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
840
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Agile that works and the tools we love
rasmusluckow
330
21k
Building an army of robots
kneath
306
46k
How STYLIGHT went responsive
nonsquared
100
5.8k
Making Projects Easy
brettharned
117
6.4k
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