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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
250
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
140
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
540
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
160
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
150
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.1k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
170
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
200
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
360
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
560
Featured
See All Featured
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
Abbi's Birthday
coloredviolet
2
8.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Balancing Empowerment & Direction
lara
6
1.2k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
370
Making the Leap to Tech Lead
cromwellryan
135
9.9k
30 Presentation Tips
portentint
PRO
1
330
Designing for Timeless Needs
cassininazir
1
260
Writing Fast Ruby
sferik
630
63k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
140
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