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
TDD in iOS
Search
Dominik Hauser
December 04, 2019
Programming
48
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TDD in iOS
German presentation about TDD in iOS
Dominik Hauser
December 04, 2019
Other Decks in Programming
See All in Programming
Foundry Localでエージェント開発
seosoft
0
180
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
0
190
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
510
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
140
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.7k
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
400
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
280
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
信頼性の目標を誰も求めてない
shubox
0
500
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
290
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
120
Featured
See All Featured
Docker and Python
trallard
47
4.2k
Prompt Engineering for Job Search
mfonobong
0
450
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
Speed Design
sergeychernyshev
33
2.1k
Six Lessons from altMBA
skipperchong
29
4.5k
The SEO identity crisis: Don't let AI make you average
varn
0
550
From π to Pie charts
rasagy
0
360
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
600
Transcript
TDD und iOS Dominik Hauser, @dasdom
The quality and performance achieved could not have been done
without the use of unit testing. — Bill Bumgarner (bbum), über Core Data 1.0
Vorteile
Vorteile1 · Refaktorierbarkeit · Schnelles Feedback · Gedankenstütze · Doppelte
Buchführung · Regressionsschutz 1 Von (subjektiv) wichtig nach unwichtig
Planning/Feedback Loops Release Plan Code Iteration Plan Acceptance Test Stand
Up Meeting Pair Negotiation Unit Test Pair Programming Months Weeks Days One day Hours Minutes Seconds DonWells (CC BY-SA 3.0)
Wie? Red Green Refactor
Warum so wenig Tests?
"Was soll denn da kaputt gehen?"
if index-1 < userNames.count { nameLabel.text = userNames[index] } else
{ nameLabel.text = "Unknown" }
if index-1 < userNames.count { nameLabel.text = userNames[index] } else
{ nameLabel.text = "Unknown" }
class TableViewCell: UITableViewCell { let label = UILabel() override init(style:
UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) addSubview(label) } }
class TableViewCell: UITableViewCell { let label = UILabel() override init(style:
UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) addSubview(label) } }
"Was soll denn da kaputt gehen?" 1. That can’t happen.
2. That doesn’t happen on my machine. 3. That shouldn’t happen. 4. Why does that happen? 5. Oh, I see. 6. How did that ever work?2 2 Mike W. Cremer
"Machen wir nach dem Release."
RELEASE 1.0 TESTS RELEASE 1.1 Login Login Tests User User
Tests Logout Logout Tests Password reset Password Tests Blocking of users Blocking tests ... ...
RELEASE 1.0 RELEASE 1.1 TESTS Login Login Tests User User
Tests Logout Logout Tests Password reset Password Tests Blocking of users Blocking tests ... ...
RELEASE 1.0 RELEASE 1.1 RELEASE 1.1.1 Login User Logout Password
reset Blocking of users ... ...
Nach den Release ist vor den Release
"UI kann man nicht testen."
func test_viewHasLabel() { sut.loadViewIfNeeded() XCTAssertTrue(sut.label.isDescendant(of: sut.view)) }
func test_loadingView_registersCell() { // when sut.loadViewIfNeeded() // then let cell
= sut.tableView.dequeueReusableCell( withIdentifier: "Cell", for: IndexPath(row: 0, section: 0)) XCTAssertNotNil(cell) XCTAssertTrue(cell is Cell) }
func test_showNext_pushesViewController() { // given let navControllerMock = NavigationControllerMock( rootViewController:
sut) let user = User(name: "Foobar") // when sut.showNext(with: user) // then let detailController = navControllerMock.lastPushedVC as! DetailViewController XCTAssertEqual(detailController.user, user) }
"UI kann man nicht testen." Kann man
Tips & Tricks
Dependency Injection (Inversion of Control)
Zum Beispiel: Constructor Injection let defaultsStub = DefaultsStub(boolToReturn: false) let
user = User(defaults: defaultsStub)
Ausserdem · Constructor Injection · Setter Injection · Interface Injection
Abstraktion
Abstraktion Beispiel: Alerts protocol Alerter { func presentOKAlert(on: UIViewController, title:
String, message: String, okAction: ()->Void) }
View laden func test_foo() { // given ... // when
view loads sut.loadViewIfNeeded() // then ... }
viewWill/DidAppear func test_foo() { // given ... // when view
appears sut.beginAppearanceTransition(true, animated: false) sut.endAppearanceTransition() // then ... }
Modal presentation func test_presentationOfViewController() { // given let window =
UIWindow(frame: CGRect(x: 0, y: 0, width: 300, height: 300)) window.rootViewController = sut window.makeKeyAndVisible() // when sut.showNext() // then XCTAssertTrue(sut.presentedViewController is DetailViewController) }
Bestehender Code Wie anfangen?
Bug ➜ Test
Neues Feature ➜ Test
pragprog.com/book/jrlegios/ ios-unit-testing-by-example
Promolink http://leanpub.com/ tdd_ios_gimme_the_cod e/c/macdev
None
Promolink http://leanpub.com/ tdd_ios_gimme_the_cod e/c/macdev
Ende
Ende!
None