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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
140
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
130
ThorVG Viewer In VS Code
nors
0
760
「ブロックテーマでは再現できない」は本当か?
inc2734
0
210
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
200
Patterns of Patterns
denyspoltorak
0
1.4k
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
190
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
160
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
2.4k
MUSUBIXとは
nahisaho
0
130
Fragmented Architectures
denyspoltorak
0
150
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
The World Runs on Bad Software
bkeepers
PRO
72
12k
Agile that works and the tools we love
rasmusluckow
331
21k
My Coaching Mixtape
mlcsv
0
46
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
Done Done
chrislema
186
16k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
170
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Utilizing Notion as your number one productivity tool
mfonobong
2
210
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
670
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