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
890
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.4k
dSYMのアップロードで SPMを活用する/use_spm_with_upload_dsyms
fromkk
1
2.6k
Bitriseのリモートアクセス機能 #bitrise_meetup/remote_access_of_bitrise
fromkk
1
520
note社でのMagic Pod活用事例 #af_iosdc/magicpod_with_note
fromkk
2
10k
iOSには無いmacOS独自機能をCatalystで実装する #iosdc #d/make_macos_apps_with_catalyst
fromkk
9
2k
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
CSC509 Lecture 09
javiergs
PRO
0
140
cmp.Or に感動した
otakakot
2
130
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
CSC509 Lecture 12
javiergs
PRO
0
160
RubyLSPのマルチバイト文字対応
notfounds
0
120
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Click-free releases & the making of a CLI app
oheyadam
2
110
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Done Done
chrislema
181
16k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
How to Ace a Technical Interview
jacobian
276
23k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
Teambox: Starting and Learning
jrom
133
8.8k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Producing Creativity
orderedlist
PRO
341
39k
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