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
batsを使おう / Let's use bats
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
cottondesu
September 16, 2018
Programming
360
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
batsを使おう / Let's use bats
bashのテストフレームワーク「bats」に
ついての簡単な例付きでご紹介
cottondesu
September 16, 2018
Transcript
31 slides
CBUTΛ͓͏ 2018年09月15日 kanazawa.rb meetup#73
!DPUUPO@EFTV ΏΔͬͱ;ΘͬͱอकΤϯδχΞ ׂ৽ن։ൃ ׂอक ػೳՃɺػೳमਖ਼ɺόάमਖ਼ FUD
CBTIॻ͍ͯ·͔͢ʁ
CBTIͰςετ Ͱ͖Δͷͬͯ·͔ͨ͠ʁ
࣮
CBUTͰग़དྷΔΜͰ͢
CBUTͱ
#BTI"VUPNBUFE 5FTUJOH4ZTUFN IUUQTHJUIVCDPNTTUFQIFOTPOCBUT
CBTIͷςετϑϨʔϜϫʔΫ w ରԠ04 "SDI "MQJOF 6CVOUV 'SFF#4%YBOEY NBD04 8JOEPXT
CBUT
Πϯετʔϧ؆୯
Πϯετʔϧ IPNFCSFXͰΠϯετʔϧ CSFXJOTUBMMCBUTDPSF OQNͰΠϯετʔϧ OQNJOTUBMMHCBUT
͍ํ
w !UFTUͷ\^ͷϒϩοΫ͕ςετର w CBUTϑΝΠϧʹهࡌ w CBUTίϚϯυͰCBUTϑΝΠϧΛ࣮ߦ ͍ํ ϧʔϧ
w TIFMMͷಡΈࠐΈTFUVQ ʹهࡌ w SVOϑΝϯΫγϣϯ໊Ͱ࣮ߦ w SVOͷ݁Ռ#BUTͷΈࠐΈมʹೖΔ ͨΊɼҎԼΛςετ݁Ռͱͯ͠༻ ͍ํ ϧʔϧ
w \TUBUVT^εςʔλείʔυ w \PVUQVU^ग़ྗ݁Ռ w \MJOFT^ग़ྗ݁Ռʢྻʣ
࡞ྫ
VTSCJOFOWCBUT !UFTUBEEJUJPOVTJOHCD\ˡ!UFTUͷ\^ͷϒϩοΫ SFTVMU FDIP cCD <SFTVMUFR> ^ !UFTUBEEJUJPOVTJOHED\ SFTVMU
FDIP QcED <SFTVMUFR> ^ BEEJUJPOCBUT
࣮ߦྫ
CBUTBEEJUJPOCBUT 㾎BEEJUJPOVTJOHCDˡ!UFTUͷ\^ͷϒϩοΫ໊ 㾎BEEJUJPOVTJOHED UFTUT GBJMVSFT
失敗例
#!/usr/bin/env bats @test "addition ng" { result="$(echo 2+1 | bc)"
[ "$result" -eq 4 ] } addition_ng.bats
実行例
CBUTBEEJUJPO@OHCBUT ✗BEEJUJPOOH JOUFTUGJMFBEEJUJPO@OHCBUT MJOF A<SFTVMUFR>GBJMFE UFTU GBJMVSF
ෳͷCBUTΛ࣮ߦՄೳ
CBUT CBUT 㾎BEEJUJPOVTJOHCD 㾎BEEJUJPOVTJOHED ✗BEEJUJPOOH JOUFTUGJMFBEEJUJPO@OHCBUT MJOF A<SFTVMUFR>GBJMFE
UFTUT GBJMVSF
TIFMMಡΈࠐΈྫ
#!/bin/sh add() { echo $(($1 + $2)) } add.sh
#!/usr/bin/env bats setup() { . add.sh } @test "input add
eq 3" { run add 1 2 [ "${status}" -eq 0 ] [ "${output}" == "3" ] } @test "input add ng" { run add 1 4 [ "${status}" -eq 0 ] [ "${output}" == "4" ] } add.bats
実行例
CBUTBEECBUT 㾎JOQVUBEEFR ✗JOQVUBEEOH JOUFTUGJMFBEECBUT MJOF A<\PVUQVU^>GBJMFE UFTUT GBJMVSF
%FNP
w Πϯετʔϧ͍ํ؆୯ w ςετίʔυͷॻ͖ํ؆୯ w CBTIʹΑΔςετϥΠϑΛ࢝Ί·͠ΐ͏ ૯ׅ
More Decks by cottondesu
See All by cottondesu
在庫管理・買い物メモを作成中/creating-inventory-management-shopping-list
cottondesu
0
23
ヨシケイの撮り忘れを対策したPart2/measures-were-taken-to-prevent-forgetting-to-pick-up-yoshikei-part2
cottondesu
0
58
ヨシケイの取り忘れ対策した / Measures were taken to prevent forgetting to pick up Yoshikei
cottondesu
0
380
開発環境公開ハード編 / Development environment public hardware version
cottondesu
0
200
開発環境公開ソフト編 / Development environment public software edition
cottondesu
0
200
正規表現で心が折れた/Regular expressions broke my heart
cottondesu
0
190
オレオレGASからMakeへの移行を検討してみた / Considering the transition from Ore Ore GAS to Make
cottondesu
0
810
Kanazawa.rb 10周年KPT / Kanazawa.rb 10th Anniversary KPT
cottondesu
0
930
Kanazawa.rb 9周年KPT / Kanazawa.rb 9th Anniversary KPT
cottondesu
0
510
Other Decks in Programming
See All in Programming
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
590
Kotlin Fest 2026: Kotlin コンパイラに Contribute してみよう! - Kotlin/Wasm で深い再帰を書けるようにした話
ternbusty
1
370
ビジネスロジックを堅牢に~Scala 3のドメインプリミティブ~
j5ik2o
0
200
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
2
490
止まらない比較を止める — 余帰納法で無限ストリームを比べる
tarao
0
190
SODA - FACT BOOK(EN)
sodainc
1
260
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
310
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
210
AI時代のIaC入門 〜なぜインフラをコードで管理したいのか?〜 / Introduction to IaC in the AI Era
akihisaikeda
6
1.6k
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
450
小さなアプリを作って公開するまで
onozaty
0
200
Claude Codeのおかげでやりたいことがやれるようになったんだよォー!
sms_tech
0
150
Featured
See All Featured
Ruling the World: When Life Gets Gamed
codingconduct
0
440
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
560
Testing 201, or: Great Expectations
jmmastey
46
8.4k
Designing for humans not robots
tammielis
254
26k
Design in an AI World
tapps
1
390
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
4
1.3k
Side Projects
sachag
456
43k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.4k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
550