Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Testing UIViewControllers
Search
Rachel Bobbins
October 22, 2015
Programming
17k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
460
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
140
スマート反転とウェブアクセシビリティ
camiha
0
210
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
280
Heart of Swift Concurrency
koher
0
950
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
220
Intent as Code
shoppingjaws
6
1.1k
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2.4k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
550
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
490
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
430
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
Featured
See All Featured
Bash Introduction
62gerente
615
220k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
240
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
The Curious Case for Waylosing
cassininazir
1
520
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
KATA
mclloyd
PRO
35
15k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Between Models and Reality
mayunak
4
460
Into the Great Unknown - MozCon
thekraken
41
2.7k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
How to Think Like a Performance Engineer
csswizardry
28
2.8k
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