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
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.4k
Bluetoothわかんねぇよなぁ!ハム太郎! / Bluetooth_hamutaro
tomohikosato
4
1.3k
効率よく勉強する(Androidアプリ開発編)
tomohikosato
1
320
いかにして問題を解くか
tomohikosato
0
250
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
580
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
250
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
mrbgem 三角測量 開発
ogom
0
240
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
contenteditable と日本語入力に向き合う
colorful12
0
190
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
490
ActionController meets Protocol Buffers
sorah
0
220
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
470
APNsからLive Activityを開始する話
yumnumm
0
170
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
600
Crafting Experiences
bethany
1
380
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
450
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Tell your own story through comics
letsgokoyo
1
1.1k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
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