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
1 test 1 assert ?
Search
PoohSunny
September 30, 2017
Technology
0
360
1 test 1 assert ?
TDDBC Tokyo 2017-09 でのLTスライドです。
https://tddbc.connpass.com/event/65484/
PoohSunny
September 30, 2017
Tweet
Share
More Decks by PoohSunny
See All by PoohSunny
ドレイファスモデルの紹介 / introduce Dreyfus model
poohsunny
1
1k
Make Work Visible in Agile2018 #LINE_DM
poohsunny
1
390
タウンワークをドライブさせるためになんちゃってアジャイルをやめた話 #devsumi #devsumiB / devsumi2018
poohsunny
30
45k
XUTPから学ぶ記述性の高いユニットテスト 〜俺たちを助けるユニットテストへ〜 / xUTP in #xpjug
poohsunny
4
5.1k
XCUITestする時のTIPs 〜あなたを助けるXCUITestへ〜
poohsunny
0
3k
コードに思いが伝わる
poohsunny
0
240
横浜タネマキでGebと握手! #yokohamagroovy
poohsunny
0
380
The "yummy" licenses.
poohsunny
0
160
ブラウザテストをサクサク自動化するためのGeb実践入門 #jjug_ccc
poohsunny
21
6.9k
Other Decks in Technology
See All in Technology
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
250
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
210
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
230
DevFest 2024 Incheon / Songdo - Compose UI 조합 심화
wisemuji
0
120
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
2
110
UI State設計とテスト方針
rmakiyama
2
650
20241220_S3 tablesの使い方を検証してみた
handy
4
630
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
10個のフィルタをAXI4-Streamでつなげてみた
marsee101
0
170
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
290
LINE Developersプロダクト(LIFF/LINE Login)におけるフロントエンド開発
lycorptech_jp
PRO
0
120
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
The Invisible Side of Design
smashingmag
298
50k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
What's in a price? How to price your products and services
michaelherold
243
12k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Scaling GitHub
holman
458
140k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
4 Signs Your Business is Dying
shpigford
181
21k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Practical Orchestrator
shlominoach
186
10k
Transcript
1 test 1 assert ? 1
ߴڮ ཅଠ(@PoohSunny) { role: "Engineer team leader", lang: ["Java", "Groovy",
"Swift"] } 2
3
ϖΞϓϩσϞ 4
1 test 1 assertion 5
xUTPͱͷग़ձ͍ 6
ޙ3 3 photo: https://www.flickr.com/photos/daverusso88/20860542330/in/photolist- xMnJsW-8H8jnW-8BDdLz-fS9XhN-e3qtWG-oaibHC-eRMCCx-q9Ftni-n7Lmvm-supyFV-gXyxGZ- fEKqSK-sqqxce-sfR8k1-q7N9Ta-dDw4Zq-9ML2MP-oa6sWm-J5F4zN-4vX6LP-nW3r1Q- rF4QJJ-8BWJj9-A1MjG7-sqqpKR-HgcdWN-7Dy6QC-s7M3Dn-w2RjN3-TZXibu-mMD2tR-o9TZi6- shS8mE-hWRzr-WJPkXw-xe6Rnv-DWz4Ra-yGju6j-fkfg3o-ghz6JD-wR4HYP-7xhvzK-rN2UEW- krfJu3-Duju1z-FSwQ8h-8yNSK2-4vXc2a-DaLuo5-zZyYuS 7
xUTPͱͷग़ձ͍(ཧ)4 4 ಈը: https://engineers.sg/video/unit-test-craftsmanship-agile-singapore- conference-2016--1168 εϥΠυ: http://singapore2016.xunitpatterns.com/ 8
γϯάϧΞαʔγϣϯ9 • ࿑ಇ࣌ؒܭࢉͷςετ // then assertEquals(720, result.getWorkTime()); • ٳܜ࣌ؒܭࢉͷςετ //
then List<Integer> breakTimeList = result.getBreakTimeList(); assertEquals(2, breakTimeList.size()); assertEquals(60, breakTimeList[0]); assertEquals(45, breakTimeList[1]); 9 http://xunitpatterns.com/Principles%20of%20Test%20Automation.html#Single Condition Test 9
1 test 1 assertϗ ϯτʁ 10
·ͱΊ͓͍ͯͨํ͕ Θ͔Γͦ͢͏ // then List<Integer> breakTimeList = result.getBreakTimeList(); assertEquals(2, breakTimeList.size());
assertEquals(60, breakTimeList[0]); assertEquals(45, breakTimeList[1]); 11
ಡΈ͍͢ܗʹ ϦϑΝΫλϦϯά • ྫ͑JUnit5 + AssertJΛར༻ // then List<Integer> breakTimeList
= result.getBreakTimeList(); assertThat(breakTimeList).hasSize(2).containsExactly(60, 45); 12
ΧελϜΞαʔγϣϯ10 • ϔϧύʔΛ࡞͠ɺΞαʔγϣϯͷ࣮ॲཧͦ ͪΒʹҠಈ 10 http://xunitpatterns.com/Custom%20Assertion.html 13
ϝιουຊޠԽख // then List<Integer> breakTimeList = result.getBreakTimeList(); ٳܜ2ճܭࢉ͞Εͯ(breakTimeList, _1ͭͷܭࢉ࣌ؒ(60), _2ͭͷܭࢉ࣌ؒ(45));
14
ϝϯςφϯεੑ͕٘ਜ਼ʹͳ Δʁ • ςετͷڞ௨ԽͬͯͲΕ΄Ͳॏཁʁ • ͜ΕʹΑͬͯͲͷ͘Β͍ಡΈ͕͢͞૿͢ʁ 15
ಡΈ͘͢ͳΒͳ͍Α͏ͳΒ ͠ಡΈ͘͢ͳΒͳ͍ͳΒɺγϯάϧΞαʔγ ϣϯਥʹͳΔͭΓͳ͍Α — Principle: Verify One Condition per Test
11 11 http://xunitpatterns.com/Principles%20of%20Test%20Automation.html#Single Condition Test ΑΓҙ༁ 16
Single Assertion ૉΒ͍͠ 17
Ͱόϥϯε͋Δ Αʂ 18
͓͠·͍ 19