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
17k
3
Share
Testing UIViewControllers
Slides from lightning talk given 10/22 @ Swift Language User Group
Rachel Bobbins
October 22, 2015
More Decks by Rachel Bobbins
See All by Rachel Bobbins
Your Refactoring Toolbox
rbobbins
1
190
Design of Everyday Swift
rbobbins
1
18k
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
120
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
520
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
27
19k
ハーネスエンジニアリングとは?
kinopeee
13
6.7k
My daily life on Ruby
a_matsuda
3
180
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.5k
AgentCore Optimizationを始めよう!
licux
3
180
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.8k
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.6k
Road to RubyKaigi: Play Hard(ware)
makicamel
1
540
AI-DLC Deep Dive
yuukiyo
9
5.5k
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
510
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
410
Building an army of robots
kneath
306
46k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Producing Creativity
orderedlist
PRO
348
40k
[SF Ruby Conf 2025] Rails X
palkan
2
1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Automating Front-end Workflow
addyosmani
1370
200k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
The Curse of the Amulet
leimatthew05
1
12k
Exploring anti-patterns in Rails
aemeredith
3
350
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
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