#!/usr/bin/env bats @test "1+1 should equal to 2" { [ "$((1+1))" -eq 2 ] } @test "When test.sh is passed 'hoge', it should output 'hoge'" { run ./test.sh "hoge" [ $status -eq 0 ] [[ $output =~ hoge ]] } @test "When test.sh doesn't have arguments, it should show usage" { run ./test.sh [ $status -eq 1 ] local usage="usage: test.sh <message>" [[ $output =~ $usage ]] } @test "Whey say function is pass
![BatsでシェルスクリプトやCLIプログラムのテストをする | デバッグライフ](https://cdn-ak-scissors.b.st-hatena.com/image/square/c183c544c6cb7ca0d066fe42e13bcf7a0d19a1cc/height=288;version=1;width=512/https%3A%2F%2Fi0.wp.com%2Fdebug-life.net%2Fwp-content%2Fuploads%2F2016%2F05%2Fbash.png%3Ffit%3D282%252C262%26ssl%3D1)