Test your bash scripts in the fastest and simplest way, discover the most modern bash testing library.
./bashunit <test_script>
# example/logic.sh
echo "expected $1"
# example/logic_test.sh
SCRIPT="./logic.sh"
function test_your_logic() {
assertEquals "expected 123" "$($SCRIPT "123")"
}
Check out the example directory for more.
Although there's no Bash script dependency manager like npm
for JavaScript, Maven
for Java, pip
for Python, or composer
for PHP; you can install this project in your repository according to your preferences. Here, I provide a Git submodule option that will work for you.
You can use Git submodules to include external Git repositories within your project. This approach works well for including Bash scripts or other resources from remote repositories.
git submodule add [email protected]:TypedDevs/bashunit.git tools/bashunit
To update a git-submodule:
- keep the git-submodule under your git (committed)
- go inside the git-submodule and:
git submodule update --remote
(preferred)- or pull
main
- or checkout a concrete release tag
You are welcome to contribute reporting issues, sharing ideas, or with your Pull Requests.