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
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
350
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
140
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
2.9k
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
500
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
220
浮動小数の比較について
kishikawakatsumi
0
360
CSC307 Lecture 14
javiergs
PRO
0
440
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
190
RubyとGoでゼロから作る証券システム: 高信頼性が求められるシステムのコードの外側にある設計と運用のリアル
free_world21
0
140
コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions
handlename
0
120
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.6k
文字コードの話
qnighy
43
16k
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
130
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
120
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
260
Code Reviewing Like a Champion
maltzj
527
40k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
200
Product Roadmaps are Hard
iamctodd
PRO
55
12k
A designer walks into a library…
pauljervisheath
210
24k
Everyday Curiosity
cassininazir
0
150
4 Signs Your Business is Dying
shpigford
187
22k
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