Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
テストデータについて
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
8yabusa
March 19, 2018
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
テストデータについて
AndroidTestNight#3の発表資料です
8yabusa
March 19, 2018
More Decks by 8yabusa
See All by 8yabusa
BLEアプリ設計パターン / ble_app_pattern
tomohikosato
10
3.3k
Bluetoothわかんねぇよなぁ!ハム太郎! / Bluetooth_hamutaro
tomohikosato
4
1.3k
効率よく勉強する(Androidアプリ開発編)
tomohikosato
1
320
いかにして問題を解くか
tomohikosato
0
250
Other Decks in Programming
See All in Programming
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
150
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
個人開発基盤をまるごとCloudflareに引っ越して爆速で総合的体験を向上させた話
tinykitten
0
200
新卒PdEのリアル
ryu1013
1
510
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
460
JRuby: Past, Present, and Future
headius
0
170
速習iPhone Duo対応
yuukiw00w
1
700
Java 27新機能 / Java 27 new features
kishida
2
150
Webの地図
yosuke_furukawa
PRO
6
4.7k
Intent as Code
shoppingjaws
6
1.1k
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
380
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.7k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
My Coaching Mixtape
mlcsv
0
320
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
Six Lessons from altMBA
skipperchong
29
4.5k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
370
The Curse of the Amulet
leimatthew05
3
15k
Transcript
テストデータについて Tomohiko Sato
⾃⼰紹介 • Tomohiko Sato @8yabusa • Qrio.inc (2017年10⽉~) • テストは主に本で読んだ知識で実践
テストデータについて 具体例で考えよう
視聴回数、どんな⾵に表⽰されるか? • 万、億単位がある (例: 32回、 256 万回、3億回) • 3桁⽬にカンマがある (例:
1,353 回、3,245万回) 例: Youtube
ViewCount(58).show() // 58回 ViewCount(43453).show() // 4万回 実装したとする
ViewCount(58).show() // 58回 ViewCount(43453).show() // 4万回 テストどうしよう?
• テストは特定のケースで成功/失敗することしか⽰せない • Intが取りうる値の範囲 = 2^32通りのテストするのか? • じゃあどのケースでテストする? 完璧なテストなど存在しない
Q. そもそも何のためにテスト しているのか A1. テスト対象が仕様通りに動いて欲しいから A2. テスト対象がバグって欲しくないから
A1.テスト対象が仕様通りに 動いて欲しい • 仕様をグループ分け(同値分割)、グループに属する適当 な値を選びテスト • 億回、万回、回とグループ分けし、適当な値でテ スト • カンマあり、カンマとグループ分けし、適当な値
でテスト
A2. テスト対象がバグって欲しくな い • バグを引き起こしそうなテストデータを⽤意する • グループの変わり⽬ ( = 境界値)
• 9999, 10000 -> 9,999回、1万回 (桁の変わり⽬) • 300, 3,000 -> 300回、 3,000回 (カンマが付く、付 かないの変わり⽬) • 特殊な値 • 0, INT_MAXとか
こんな感じ(?) * いろんな桁でテスト * 単位の変わり⽬目、カンマがつく、付かないに特に着⽬目 * 0とか9999, 10000でテスト * -1とか異異常な値は、インスタンス⽣生成時に弾かれる。テストしたければ別途テスト
どこが失敗したかわかり⾟い
パラメタライズドテスト JUnitParams
まとめ • 完全なテストは存在しない、それっぽい値でテストする必要がある • 仕様を満たしていると⾔えそうな値を⽤意 • 仕様をグループ分けして適当な値でテスト • プログラマがミスりそうな値を⽤意 •
例えばメソッドの出⼒が変わる境界の値 • いろんな値をテストする場合はパラメタライズドテストが便利 • JUnit4標準のは微妙なので、JUnitParamsか、JUnit5を使おう
• 完全なテストは存在しない、それっぽい値でテストする必要がある • 仕様を満たしていると⾔えそうな値を⽤意 • 仕様をグループ分けして適当な値でテスト • プログラマがミスりそうな値を⽤意 • 例えばメソッドの出⼒が変わる境界の値
• いろんな値をテストする場合はパラメタライズドテストが便利 • JUnit4標準のは微妙なので、JUnitParamsか、JUnit5を使おう ありがとうございました !
参考リンク • テスト7原則について http://www.itmedia.co.jp/im/ articles/1111/07/news192.html • テストは⽋陥があることしか⽰せない • 全数テストは不可能 •
JUnitParams https://github.com/Pragmatists/JUnitParams • JUnit5 ParameterizedTest https://junit.org/junit5/docs/ current/user-guide/#writing-tests-parameterized-tests