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
shigeru. nakajima
July 11, 2022
Programming
800
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
パラメタライズドテスト
社内向けにパラメタライズドテストを紹介したときの資料です。
おもにRubyist向けで、RSpecでのテストの書き方をわかっている人向けです。
shigeru. nakajima
July 11, 2022
More Decks by shigeru. nakajima
See All by shigeru. nakajima
.NETでruby.wasmを動かしてみた
ledsun
0
99
Introduce dRuby
ledsun
0
580
Watching Ruby in browsers
ledsun
0
360
Using Ruby in the browser is wonderful
ledsun
1
5.3k
Rubyで書いたテトリスをブラウザで動かしてみた
ledsun
0
2.7k
ruby.wasm に関する進捗報告
ledsun
0
1.5k
Hacking Guide of the ruby.wasm
ledsun
0
2.1k
私の作ったruby.wasm アプリケーション
ledsun
0
910
Load gem from browser
ledsun
2
2.2k
Other Decks in Programming
See All in Programming
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
0
270
新人はどこまで自力でやり、どこからAIに頼るべきか/エンジニア育成に向き合う_先輩たちの悩みと知見共有会
toppan_digital_dev
1
620
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
350
GKE で Pod の見方を変えたら、スケールアウト時の挙動を真に捉えられた話
stkk
0
120
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
240
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
110
型解析で実現する Go の言語内 DSL / Conference に Go! タイムテーブルの歩き方 for Gophers
mazrean
0
150
Webの地図
yosuke_furukawa
PRO
6
4.5k
スマート反転とウェブアクセシビリティ
camiha
0
210
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
3
340
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
240
What We Talk About When We Talk About XP
m_seki
2
620
Featured
See All Featured
Exploring anti-patterns in Rails
aemeredith
4
510
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
690
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
The untapped power of vector embeddings
frankvandijk
2
1.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
450
Un-Boring Meetings
codingconduct
0
420
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
280
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
330
Between Models and Reality
mayunak
4
460
Transcript
パラメタライズドテスト 2022/07/08 株式会社ラグザイア 中島 滋
パラメタライズドテストとは? テストコードの書き方 名前がかっこいい 2 2
FizzBuzz 3 3
1から100までの数に対して 3で割り切れる数はFIZZ 5で割り切れる数はBUZZ 3でも5でも割り切れる数はFIZZBUZZと表示する。 それ以外の数は数字のまま表示する。 4 4
どんなテストをかきますか? 5 5
まず 3、5、15は入力します。 他にはなにかいれますか? 6 6
3、5、15のまわりの数字はどうでしょうか? 2, 4, 6, 14, 16 ... 7 7
1から100までの数 以外はどうなるでしょう? 0、1と100、101 も確認したいです。 8 8
RSpecで 9 9
context '数が1より小さいとき' do it { expect(fizzbuzz 0).to eq '' }
end context '数が100より大きいとき' do it { expect(fizzbuzz 101).to eq '' } end context '数が3で割り切れるとき' do it { expect(fizzbuzz 3).to eq 'FIZZ' } it { expect(fizzbuzz 6).to eq 'FIZZ' } it { expect(fizzbuzz 9).to eq 'FIZZ' } end 10 10
context '数が5で割り切れるとき' do it { expect(fizzbuzz 5).to eq 'BUZZ' }
it { expect(fizzbuzz 10).to eq 'BUZZ' } it { expect(fizzbuzz 20).to eq 'BUZZ' } end context '数が15で割り切れるとき' do it { expect(fizzbuzz 15).to eq 'FIZZBUZZ' } it { expect(fizzbuzz 30).to eq 'FIZZBUZZ' } it { expect(fizzbuzz 45).to eq 'FIZZBUZZ' } end 11 11
context '数が3でも5でも割り切れないとき' do it { expect(fizzbuzz 1).to eq '1' }
it { expect(fizzbuzz 2).to eq '2' } it { expect(fizzbuzz 4).to eq '4' } it { expect(fizzbuzz 7).to eq '7' } it { expect(fizzbuzz 8).to eq '8' } it { expect(fizzbuzz 11).to eq '11' } it { expect(fizzbuzz 13).to eq '13' } it { expect(fizzbuzz 14).to eq '14' } it { expect(fizzbuzz 16).to eq '16' } end 12 12
expect(fizzbuzz 3).to eq 'FIZZ' が、一杯でてくるのが気になる。 13 13
Don't repeat yourself 14 14
アサーション(expect~)の重複を解消する パラメタライズドテスト 15 15
[ [0, ''], [1, '1'], [2, '2'], [3, 'FIZZ'], [4,
'4'], [5, 'BUZZ'], # 中略 [101, ''] ].each do | number, answer | it { expect(fizzbuzz number).to eq answer } end 配列で、入力値と期待する結果をまとめる expect(fizzbuzz number).to eq answer をひとつに 16 16
パラメタライズドテストを サポートしている テスティングフレームワーク 17 17
NUnit 18 18
[TestCase(0, ExpectedResult = "")] [TestCase(1, ExpectedResult = "1")] [TestCase(2, ExpectedResult
= "2")] [TestCase(3, ExpectedResult = "FIZZ")] [TestCase(4, ExpectedResult = "4")] [TestCase(5, ExpectedResult = "BUZZ")] // 中略 [TestCase(14, ExpectedResult = "14")] [TestCase(15, ExpectedResult = "FIZZBUZZ")] [TestCase(16, ExpectedResult = "16")] [TestCase(100, ExpectedResult = "BUZZ")] [TestCase(101, ExpectedResult = "")] public string FizzBuzzTest(int number) { return FizzBuzz(number); } 属性でパラメーターと期待する値を指定 テストケースはひとつ 19 19
自分でeachやブロックを書かなくてよい 誰が書いても同じ書き方になる テストコードが読みやすい 20 20
.NET の世界のから 21 21
自慢 情報共有 22 22