2024-08-30 BATS(Bash Automated Testing System)でBashのテスト
Bash Script のテスト書くのにBATS(Bash Automated Testing System) 使ってみたけど、直感的にテストがかけて体験良かった » bats-core/bats-core: Bash Automated Testing System https://t.co/Np7kSqhqrY
— toshimaru (@toshimaru_e) August 30, 2024
サンプルコード
#!/usr/bin/env bats
@test "addition using bc" {
result="$(echo 2+2 | bc)"
[ "$result" -eq 4 ]
}
@test "addition using dc" {
result="$(echo 2 2+p | dc)"
[ "$result" -eq 4 ]
}
bats でテストを書いたPR
ci: Setup test with BATS by toshimaru · Pull Request #2 · toshimaru/gh-workflow-log-cleaner