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
2.8k
何故テストが書けないのか #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.8k
1年分のデータが見たいと言われてやったこと/yearly_data_with_note
fromkk
0
920
note iOSチームの自動化 ver.2021/automation_with_iOS_team_on_note_ver2021
fromkk
0
1.9k
Bitrise体験会説明資料/bitrise_explore
fromkk
1
1k
noteのiOSアプリで実装したアクセシビリティの全て #iosdc #a /a11y_with_iOS_App_on_note
fromkk
2
3.6k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
2.7k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
550
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
11k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2.1k
Other Decks in Programming
See All in Programming
機能が複雑化しても 頼りになる FactoryBotの話
tamikof
0
110
15分で学ぶDuckDBの可愛い使い方 DuckDBの最近の更新
notrogue
3
490
CI改善もDatadogとともに
taumu
0
200
楽しく向き合う例外対応
okutsu
0
590
Serverless Rust: Your Low-Risk Entry Point to Rust in Production (and the benefits are huge)
lmammino
1
150
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
250
Go 1.24でジェネリックになった型エイリアスの紹介
syumai
2
280
Rails 1.0 のコードで学ぶ find_by* と method_missing の仕組み / Learn how find_by_* and method_missing work in Rails 1.0 code
maimux2x
1
140
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
980
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
5
960
なぜイベント駆動が必要なのか - CQRS/ESで解く複雑系システムの課題 -
j5ik2o
14
4.6k
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
40
16k
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Become a Pro
speakerdeck
PRO
26
5.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
How to Ace a Technical Interview
jacobian
276
23k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
52k
Faster Mobile Websites
deanohume
306
31k
Statistics for Hackers
jakevdp
797
220k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
Six Lessons from altMBA
skipperchong
27
3.6k
Unsuck your backbone
ammeep
669
57k
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