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
何故テストが書けないのか #ios_test_night /why_we_cannot_wri...
Search
fromkk
December 05, 2017
Programming
1
3k
何故テストが書けないのか #ios_test_night /why_we_cannot_write_test
2017/12/05(火)DeNAさんで開催されたiOS Test Night #6 - 1周年 - で発表した内容です。
fromkk
December 05, 2017
Tweet
Share
More Decks by fromkk
See All by fromkk
note社の全員野球で品質向上活動について / note_qa_challenge #iOS_test_teatime
fromkk
3
1.9k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
1k
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
2k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1.1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
4.5k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
3.1k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
650
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
11k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2.2k
Other Decks in Programming
See All in Programming
CSC307 Lecture 09
javiergs
PRO
1
830
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
110
dchart: charts from deck markup
ajstarks
3
990
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
260
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.8k
MUSUBIXとは
nahisaho
0
130
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
190
AI時代の認知負荷との向き合い方
optfit
0
150
CSC307 Lecture 08
javiergs
PRO
0
670
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
550
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
180
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
What's in a price? How to price your products and services
michaelherold
247
13k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
320
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
79
Documentation Writing (for coders)
carmenintech
77
5.2k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Transcript
Կނςετ͕ॻ͚ͳ͍ͷ͔ iOS Test Night #6 1
Profile Kazuya Ueoka Timers inc.ͷiOSΤϯδχΞ Twitter: @fromkk Github: fromkk Qiita:
fromkk Sarahah: fromkk 2
3
4
ʊਓਓਓਓਓʊ ʼɹςετ0ɹʻ ʉY^Y^Y^Yʉ 5
ςετΛͪΌΜͱ ॻ͔ͳ͍ͱͳʔͱࢥ͍ͬͯ·ͨ͠ 6
͊͞ɺطଘίʔυʹ ςετΛॻ͜͏ 7
ͱࢥͬͯ طଘίʔυΛோΊ·͢ 8
! 9
μϝͩɺςετॻ͚ͳ͍ 10
Կނͳͷ͔ 11
ςετ͕ॻ͚ͳ͍งғؾ • ViewControllerͰ࣮σʔλʹΞΫηε • ຊ൪αʔόʔ/ϩʔΧϧDB/UserDefaults • ίʔυͰγϯάϧτϯݺͼग़͠ • ҰͭͷΫϥε͕Λ͍࣋ͪ͗ͯ͢Δ(અࢠ) •
ΠϕϯτϋϯυϦϯά/delegate/Notification/Observation ͷॲཧΛશ͚ͯෛ͍ͬͯΔ 12
ςετ 0ݸ ͳϓϩδΣΫτʹ ϢχοτςετΛՃͯ͠Έͨ 13
ରͷը໘ 14
ࠓճͷςετͷ؍ • ը໘ىಈ࣌ʹMarkdownϑΝΠϧΛಡΈࠐΜͰtextViewͷॳ ظʹઃఆ͞Ε͍ͯΔࣄ • อଘ͍ͨ͠λΠϛϯάͰอଘ͞ΕΔࣄ 15
ͬͨࣄ ͦͷ1 16
ςετதRealmΛInMemoryػೳΛ༗ޮʹ class DB { static var isTesting: Bool = false
private static var userConfiguration: Realm.Configuration { return Realm.Configuration() } private static var inMemoryConfiguration: Realm.Configuration { return Realm.Configuration(inMemoryIdentifier: "InMemory") } static var realm: Realm { let configuration: Realm.Configuration if isTesting { configuration = inMemoryConfiguration } else { configuration = userConfiguration } return try! Realm(configuration: configuration) } } 17
ͬͨࣄ ͦͷ2 18
ʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹઃܭͷݟ͠ʂʂʂɹʻ ʉY^Y^Y^Y^Y^Y^Y^Y^Y^Yʉ 19
͜Ε·Ͱ 20
ݟ͠ޙ 21
ςετ @testable import Type class RegisterViewControllerTests: XCTestCase { class MockRegistrable:
MarkdownRegistrable { let defaultValue = "Hello world" func open(_ completed: @escaping (String) -> ()) { completed(defaultValue) } var isSaved: Bool = false func save(with markdown: String) { isSaved = true } } private func makeViewController() -> RegisterViewController { let registrable = MockRegistrable() let viewController = RegisterViewController() viewController.registrable = registrable return viewController } func testOpen() { let viewController = makeViewController() viewController.open() XCTAssetEqual(registrable.textView.text, "Hello world") } func testSave() { let viewController = makeViewController() viewController.save(with: "hoge huga") XCTAssetTrue(registrable.isSaved) } } 22
ςετ͕ॻ͚ͨ 23
ςετΛॻ͍ͯݟͯ • ςετ͕ॻ͚Δ͔Ͳ͏͔ઃܭ࣍ୈͱ͍͏ࣄ͕ʹ͠Έͯ ͔ͬͨ • ϓϩύςΟ͕ࠩ͠ସ͕͑Մೳɾ֎͔Β͕ͤΔ༷ʹͳͬ ͍ͯΔࣄ͕ॏཁ • (࣮ίʔυͰ͏গ͠ςετΛॻ͍͕ͨ)؍ͷ࿙Εʹؾ ͘ࣄ͕ग़དྷͨ
24
·ͱΊ • ςετෆՄೳΛςετՄೳʹม͑Δࣄ͕ग़དྷ·ͨ͠ • ςετ͕ग़དྷͳ͍࣌ઃܭΛݟ͢ • ઃܭΛݟͤςετ͕ग़དྷΔ • େ෯ʹઃܭΛม͑ͯςετ͕͋ΔͷͰ҆৺ 25
PR 26
27
28
29
ΤϯδχΞืूத 30
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 31