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
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
Architectural Extensions
denyspoltorak
0
280
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
組織で育むオブザーバビリティ
ryota_hnk
0
170
Fluid Templating in TYPO3 14
s2b
0
130
AI時代の認知負荷との向き合い方
optfit
0
150
Oxlint JS plugins
kazupon
1
860
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
680
2026年 エンジニアリング自己学習法
yumechi
0
130
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
610
CSC307 Lecture 04
javiergs
PRO
0
660
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
64
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
49
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
Claude Code のすすめ
schroneko
67
210k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
320
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
110
The Curious Case for Waylosing
cassininazir
0
230
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