Testing Bash scripts
When you need to test a bash
script you can use bats
for that. That's how it is done:
#!/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 ]
}
Full article with different tools overview: https://medium.com/wemake-services/testing-bash-applications-85512e7fe2de
Written by sobolevn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#