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
12k
開発を効率化するテストのデザインパターン
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
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
欠陥を早期に発見するための Software Engineer in Test とその重要性 / What is Software Engineer in Test and How they works
orgachem
PRO
21
4k
住宅を WebXR で評価しよう / Evaluating My Home by WebXR
orgachem
PRO
0
84
HOME VR
orgachem
PRO
1
790
uGUI の自動操作の考え方と操作方法
orgachem
PRO
1
1.4k
Swift Macro に備えて構文木を 10min で学ぶ / Learn Syntax Tree for Swift Macro in 10 minutes
orgachem
PRO
1
1.1k
SoftWare Engineer in Test のおしごと / What is SWET
orgachem
PRO
1
1k
私と Nature Remo E / Nature Remo E
orgachem
PRO
0
25k
存在しないアセットへの参照と 未公開アセットでのネタバレに どう立ち向かうか / How to prevent missing assets and spoilers by assets
orgachem
PRO
1
1.1k
Other Decks in Programming
See All in Programming
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
42 best practices for Symfony, a decade later
tucksaun
1
180
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
第5回日本眼科AI学会総会_AIコンテスト_3位解法
neilsaw
0
170
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
ドメインイベント増えすぎ問題
h0r15h0
1
230
CSC509 Lecture 14
javiergs
PRO
0
140
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
720
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
Featured
See All Featured
Embracing the Ebb and Flow
colly
84
4.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
GitHub's CSS Performance
jonrohan
1030
460k
Faster Mobile Websites
deanohume
305
30k
Visualization
eitanlees
146
15k
The Cost Of JavaScript in 2023
addyosmani
45
7k
4 Signs Your Business is Dying
shpigford
181
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Building Applications with DynamoDB
mza
91
6.1k
Speed Design
sergeychernyshev
25
670
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
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⒎Λܭࢉ
ͬͯΈ͍ͯͩ͘͞ʂ ˒Β͑Δͱخ͍͠Ͱ͢ʂ
·ͱΊ ͞·͟·ͳύλʔϯΛۦͯ͠ ޮతʹ։ൃ͠·͠ΐ͏
Φεεϝͷࢿྉ ςετքͰ༗໊ͳ σβύλຊ ϞοΫεύΠελϒͷ ఆٛɺࠓհͨ͠ ύλʔϯͷൃݩ͕ ͨ͘͞Μࡌͬͯ·͢