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
Testing UIViewControllers
Search
Rachel Bobbins
October 22, 2015
Programming
3
17k
Testing UIViewControllers
Slides from lightning talk given 10/22 @ Swift Language User Group
Rachel Bobbins
October 22, 2015
Tweet
Share
More Decks by Rachel Bobbins
See All by Rachel Bobbins
Your Refactoring Toolbox
rbobbins
1
170
Design of Everyday Swift
rbobbins
1
18k
Other Decks in Programming
See All in Programming
快速入門可觀測性
blueswen
0
350
ドメインイベント増えすぎ問題
h0r15h0
2
300
testcontainers のススメ
sgash708
1
120
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
910
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
470
Haze - Real time background blurring
chrisbanes
1
510
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
770
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
3
700
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
103 Early Hints
sugi_0000
1
230
Featured
See All Featured
Designing for Performance
lara
604
68k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Typedesign – Prime Four
hannesfritz
40
2.4k
Code Review Best Practice
trishagee
65
17k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Facilitating Awesome Meetings
lara
50
6.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Transcript
Testing UIViewControllers Rachel Bobbins
Motivation Why do I care? Why should you care?
Motivation Why do I care? Why should you care? The
UIViewController controls the user’s experience.
Motivation Why do I care? Why should you care? The
UIViewController controls the user’s experience. It should be a good one.
Motivation Why do I care? Why should you care? The
UIViewController controls the user’s experience. It should be a good one. (Don’t you think so?)
But wait... • I don’t need view controller tests–I have
UI tests!
Demo App
A quick note about testing tools
2 Principles
Principle 1: Test the interface.
Example: Button tap https://youtu.be/2w7j--b9-Xo
Example: Button tap
Example: Button tap Tip #1: Names that describe behavior, not
methods
Example: Button tap Tip #2: Write a “tap” helper. Then,
you can just do “button.tap()”
Principle 2: Inject all the dependencies
Why? This line of code Should pass this test…
Why? This line of code Should pass this test…
Why? This line of code Should pass this test… Ohh
UIKit.
Example Dependency: Dialog Presenter!!! Tip #3: Use protocols.
Example Dependency: Dialog Presenter!!! Tip #3: Use protocols.
Example Dependency: Dialog Presenter!!! Tip #3: Use protocols. If a
view controller needs it, it needs conform to a protocol
Example Dependency: Dialog Presenter!!!
Example Dependency: Dialog Presenter!!!
Example Dependency: Dialog Presenter!!! Tip #4: Invest in fakes.
Example Dependency: Dialog Presenter!!! Tip #4: Invest in fakes.
Example Dependency: Dialog Presenter!!! Tip #4: Invest in fakes. Boolean
properties keep track of which methods were called
Example Dependency: Dialog Presenter!!! Tip #4: Invest in fakes. Boolean
properties keep track of which methods were called Tuple properties keep track of the arguments
Example Dependency: Dialog Presenter!!! Write tests that read like English
sentences
FYI + Resources - Demo code is on GitHub: https://github.
com/rbobbins/earthquake-counter - PivotalCoreKit has useful helpers for simulating interactions (i.e - tap) https://github. com/pivotal/PivotalCoreKit/tree/master/UIKit/SpecHelper/E xtensions