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
180
Design of Everyday Swift
rbobbins
1
18k
Other Decks in Programming
See All in Programming
AIエージェントの設計で注意するべきポイント6選
har1101
6
2.9k
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.5k
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
150
Tinkerbellから学ぶ、Podで DHCPをリッスンする手法
tomokon
0
150
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
210
[AI Engineering Summit Tokyo 2025] LLMは計画業務のゲームチェンジャーか? 最適化業務における活⽤の可能性と限界
terryu16
2
210
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
1k
AtCoder Conference 2025
shindannin
0
880
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
1
250
Combinatorial Interview Problems with Backtracking Solutions - From Imperative Procedural Programming to Declarative Functional Programming - Part 2
philipschwarz
PRO
0
130
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
37k
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.4k
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
1
1.5k
Ruling the World: When Life Gets Gamed
codingconduct
0
120
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
WCS-LA-2024
lcolladotor
0
400
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
SEO for Brand Visibility & Recognition
aleyda
0
4.1k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
65
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
170
Designing Experiences People Love
moore
143
24k
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