Writing Tests for Shell Scripts
Writing Tests for Shell Scripts
Testing shell scripts using Bats-core (Bash Automated Testing System):
# test/math.bats
@test "addition calculates correctly" {
result="$(./calc.sh 2 3)"
[ "$result" -eq 5 ]
}
@test "missing argument throws exit code 1" {
run ./calc.sh
[ "$status" -eq 1 ]
}