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
開発を効率化するテストのデザインパターン
Search
Kuniwak
PRO
March 13, 2017
Programming
37
13k
開発を効率化するテストのデザインパターン
2017/3/13 iOS Test Night #3
https://testnight.connpass.com/event/49561/
Kuniwak
PRO
March 13, 2017
Tweet
Share
More Decks by Kuniwak
See All by Kuniwak
DeNA での思い出 / Memories at DeNA
orgachem
PRO
3
1.5k
それ CLI フレームワークがなくてもできるよ / Building CLI Tools Without Frameworks
orgachem
PRO
17
4k
状態遷移図を書こう / Sequence Chart vs State Diagram
orgachem
PRO
4
350
テストケースの名前はどうつけるべきか?
orgachem
PRO
2
590
欠陥を早期に発見するための Software Engineer in Test とその重要性 / What is Software Engineer in Test and How they works
orgachem
PRO
21
4.5k
住宅を WebXR で評価しよう / Evaluating My Home by WebXR
orgachem
PRO
0
180
HOME VR
orgachem
PRO
1
810
uGUI の自動操作の考え方と操作方法
orgachem
PRO
1
1.5k
Swift Macro に備えて構文木を 10min で学ぶ / Learn Syntax Tree for Swift Macro in 10 minutes
orgachem
PRO
1
1.5k
Other Decks in Programming
See All in Programming
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
13
7.5k
kiroでゲームを作ってみた
iriikeita
0
180
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
190
一人でAIプロダクトを作るための工夫 〜技術選定・開発プロセス編〜 / I want AI to work harder
rkaga
13
2.8k
パスタの技術
yusukebe
1
400
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
140
Jakarta EE Core Profile and Helidon - Speed, Simplicity, and AI Integration
ivargrimstad
0
190
Flutter로 Gemini와 MCP를 활용한 Agentic App 만들기 - 박제창 2025 I/O Extended Seoul
itsmedreamwalker
0
150
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
590
TDD 実践ミニトーク
contour_gara
0
140
あのころの iPod を どうにか再生させたい
orumin
2
2.5k
SOCI Index Manifest v2が出たので調べてみた / Introduction to SOCI Index Manifest v2
tkikuc
1
110
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Rails Girls Zürich Keynote
gr2m
95
14k
A better future with KSS
kneath
239
17k
Bash Introduction
62gerente
614
210k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Docker and Python
trallard
45
3.5k
Embracing the Ebb and Flow
colly
87
4.8k
GitHub's CSS Performance
jonrohan
1031
460k
Building an army of robots
kneath
306
46k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
Transcript
։ൃΛޮԽ͢Δ ςετͷσβΠϯύλʔϯ
"CPVUNF
4XJGUϲ݄ͷਓؒ ࢦఠɾΞυόΠεܴʂ
ࠓհ͢Δύλʔϯ
ܕʹΑΔޚ
ςετ ༰қઃܭ
ςετͷ ߏԽ
σόοάͷ ޮԽ
લͷͷ΄ͲΦεεϝ
࣮ྫ͋Γ·͢
None
None
ܕʹΑΔޚ
ͦͦςετͬͯ ޮతͳͷͩΖ͏͔ʁ
ߏจϋΠϥΠτ Ϧϯτ ੩తܕݕࠪ ୯ମɾ݁߹ςετ &&ςετ खಈಈ࡞֬ೝ όά9Λݟ͚ͭͨॴ όά9
ߏจϋΠϥΠτ Ϧϯτ ੩తܕݕࠪ ୯ମɾ݁߹ςετ &&ςετ खಈಈ࡞֬ೝ όά" ্ͷํͰࢭ·Δͱ ॴཁ͕͍࣌ؒ όά#
ςετͩͱ͕࣌ؒ ͔͔Δ
ͳΔ͘ςετલʹ όάΛݟ͚͍ͭͨ ͜Ε͕ޮత
Semantic Type σβΠϯύλʔϯ
จࣈྻͱͯ͠ͷૢ࡞ ඞཁͳ͍ͷͰӅ͢ ҙຯʹΑΔಠࣗܕ 5FTUBCMF%FTJHO&YBNQMF(JU)VC(JU)VC6TFSTXJGU--
Ϣʔβʔ໊Λड͚औΕΔ ؔʹ͔ͤ͠ͳ͍ 5FTUBCMF%FTJHO&YBNQMF(JU)VC(JU)VC3FQPTJUPSZTXJGU--
ؒҧͬͨॲཧΛॻ͖ͮΒ͍ Մಡੑߴ·Δ
Registration Token σβΠϯύλʔϯ
ඞཁͳࣄલͷॲཧΛ Εͳ͍Α͏ʹ͢Δύλʔϯ
5PLFO͕ඞཁ 5BCMF7JFX$FMMΛ࡞Δؔ 5FTUBCMF%FTJHO&YBNQMF.WD"SDIJUFDUVSF4UBSHB[FST4UBSHB[FS$FMMTXJGU--
উखʹ࡞Εͳ͍ ొ͢ΔͱೖखͰ͖Δ 5FTUBCMF%FTJHO&YBNQMF.WD"SDIJUFDUVSF4UBSHB[FST4UBSHB[FS$FMMTXJGU--
ඞཁͳࣄલͷॲཧΛΕΔͱ ܕݕࠪʹ௨Βͳ͍
ςετ ༰қઃܭ
ਓؒςετ༰қͳ ͷ͔͠ςετͰ͖ͳ͍
ViewController Factory σβΠϯύλʔϯ
3FOBNFͳͲͰ 4UPSZCPBSEͱͷ߹ੑ ؆୯ʹյΕΔ 5)&ݫ͍͠
7JFX$POUSPMMFSͷ࡞ؔ 'PSDF6OXSBQܕ͜͜Ͱଋറ 5FTUBCMF%FTJHO&YBNQMF.WD"SDIJUFDUVSF4UBSHB[FST4UBSHB[FST.WD$PNQPTFSTXJGU--
͜͜Ͱ׆͖Δ 7JFX$POUSPMMFSͱ4UPSZCPBSEͷ߹ੑΛݕূ 5FTUBCMF%FTJHO&YBNQMF5FTUT.WD"SDIJUFDUVSF4UBSHB[FS.WD$PNQPTFS5FTUTTXJGU
͠࡞Εͳ͔ͬͨΒҟৗ ࣮ࡍʹදࣔ·Ͱ࣮ߦ 5FTUBCMF%FTJHO&YBNQMF5FTUT/BWJHBUPS5FTU/BWJHBUPSTXJGU
State-Machine Model σβΠϯύλʔϯ
.7 ͷ.PEFMͷ ཏςετ͍͠ ཏ͖͠Εͳ͍ʂ
.PEFMͷঢ়ଶભҠΛ੍ݶ ͔ͩΒ
.firstFetching .fetched(.success(x)) .fetching(.success(x)) .fetched(.failure(e)) .fetching(.failure(e)) FOVN͕ศར 5FTUBCMF%FTJHO&YBNQMF.WD"SDIJUFDUVSF4UBSHB[FST4UBSHB[FST.PEFMTXJGU--
ͦΕͧΕͷҹΛ ςετ͢Δ͚ͩͰΑ͍
.firstFetching .fetched(.success(x)) .fetching(.success(x)) .fetched(.failure(e)) .fetching(.failure(e)) ͜ͷྫͰຊͰཏ 5FTUBCMF%FTJHO&YBNQMF.WD"SDIJUFDUVSF4UBSHB[FST4UBSHB[FST.PEFMTXJGU--
ঢ়ଶ͕രൃ͢Δલʹ ঢ়ଶΛ੍ݶͯ͠ѹతཏ
ςετͷ ߏԽ
ςετ͕૿͑ΔʹͭΕ ςετࣗମͷอकੑ͕ॏཁʹͳΔ
Parameterized Test σβΠϯύλʔϯ
ྨࣅͨ͠ςετέʔε͕ ଟ͍߹ͷύλʔϯ
ςετέʔεΛ σʔλߏʹམͱ͢ ෳͷςετέʔεΛ·ͱΊΔ 5FTUT.JSSPS%J⒎,JU5FTUT%J⒎BCMF4FU5FTUTTXJGU- ˞͍͍ྫ͕αϯϓϧʹͳ͔ͬͨͷͰผ͔Βर͍ͬͯ·͢ɻ
ςετέʔεϧʔϓͰ࣮ߦ͢Δ 5FTUT.JSSPS%J⒎,JU5FTUT%J⒎BCMF4FU5FTUTTXJGU- ˞͍͍ྫ͕αϯϓϧʹͳ͔ͬͨͷͰผ͔Βर͍ͬͯ·͢ɻ
ςετέʔεΛྔ࢈Ͱ͖Δ 5FTUT.JSSPS%J⒎,JU5FTUT%J⒎BCMF4FU5FTUTTXJGU- ˞͍͍ྫ͕αϯϓϧʹͳ͔ͬͨͷͰผ͔Βर͍ͬͯ·͢ɻ
MJOFΛLFZʹ͢Δͱ ॴ͕Θ͔Γ͍͢ 5FTUT.JSSPS%J⒎,JU5FTUT%J⒎BCMF4FU5FTUTTXJGU- ˞͍͍ྫ͕αϯϓϧʹͳ͔ͬͨͷͰผ͔Βर͍ͬͯ·͢ɻ
Promisified Test σβΠϯύλʔϯ
ඇಉظςετΈ͕ଟ͍ ಡΈͮΒ͍͜ͱ͕ଟ͍
None
Ұํ+4քͰ1SPNJTFʹ ΑΔඇಉظςετ͕༏ ඇಉظͳͷऔಘͷσβΠϯύλʔϯ
J04Ͱ͍͍ͨʜ
None
BTZODͱ͍͏ ؔͰแΉ ςετέʔε 1SPNJTFΛฦ͢ 5FTUBCMF%FTJHO&YBNQMF5FTUT(JU)VC(JU)VC"QJ5FTUTTXJGU
9$5FTU$BTF ͏·͘ϒϦοδ 1SPNJTF͕ղܾ͞ΕͨΒςετޭ غ٫͞ΕͨΒςετࣦഊ 5FTUBCMF%FTJHO&YBNQMF5FTUT"TZODTXJGU
ಡΈ͍͢ ॻ͖͍͢
σόοάͷ ޮԽ
Diff Assertion σβΠϯύλʔϯ
Α͋͘Δςετ .JSSPS%J⒎,JU3&"%.&NE
ಡΊ͵
։ൃ͠·ͨ͠
͜͏͢Δͱʜ .JSSPS%J⒎,JU3&"%.&NE
None
.JSSPSͱ͍͏3FqFDUJPO"1*Λ ͬͯɺߏతͳEJ⒎Λܭࢉ
ͬͯΈ͍ͯͩ͘͞ʂ ˒Β͑Δͱخ͍͠Ͱ͢ʂ
·ͱΊ ͞·͟·ͳύλʔϯΛۦͯ͠ ޮతʹ։ൃ͠·͠ΐ͏
Φεεϝͷࢿྉ ςετքͰ༗໊ͳ σβύλຊ ϞοΫεύΠελϒͷ ఆٛɺࠓհͨ͠ ύλʔϯͷൃݩ͕ ͨ͘͞Μࡌͬͯ·͢