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
140
欠陥を早期に発見するための 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
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
790
Spatial Rendering for Apple Vision Pro
warrenm
0
110
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
720
情報漏洩させないための設計
kubotak
3
340
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
280
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
780
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
Security_for_introducing_eBPF
kentatada
0
110
命名をリントする
chiroruxx
1
420
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
5
740
CSC305 Lecture 26
javiergs
PRO
0
140
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
GraphQLとの向き合い方2022年版
quramy
44
13k
Fireside Chat
paigeccino
34
3.1k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
The Language of Interfaces
destraynor
154
24k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
A better future with KSS
kneath
238
17k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
What's in a price? How to price your products and services
michaelherold
243
12k
Designing for humans not robots
tammielis
250
25k
How STYLIGHT went responsive
nonsquared
95
5.2k
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⒎Λܭࢉ
ͬͯΈ͍ͯͩ͘͞ʂ ˒Β͑Δͱخ͍͠Ͱ͢ʂ
·ͱΊ ͞·͟·ͳύλʔϯΛۦͯ͠ ޮతʹ։ൃ͠·͠ΐ͏
Φεεϝͷࢿྉ ςετքͰ༗໊ͳ σβύλຊ ϞοΫεύΠελϒͷ ఆٛɺࠓհͨ͠ ύλʔϯͷൃݩ͕ ͨ͘͞Μࡌͬͯ·͢