Quickstart
bashunit is a dedicated testing tool crafted specifically for Bash scripts. It empowers you with tests on your Bash codebase, ensuring that your scripts operate reliably and as intended.
With an intuitive API and documentation, it streamlines the process for developers to implement and manage tests. This is beneficial regardless of the project's size or intricacy in Bash.
Thanks to bashunit, verifying and validating your Bash code has never been so easy.
Installation
There is a tool that will generate an executable with the whole library in a single file:
curl -s https://bashunit.typeddevs.com/install.sh | bash
This will create a file inside a lib folder, such as lib/bashunit
.
See more about installation.
Usage
Once bashunit is installed, you're ready to get started.
First, create a folder to place your tests:
bashmkdir tests
Next, create your first test file named
example_test.sh
within this folder:bash#!/bin/bash function test_bashunit_is_working() { assert_same "bashunit is working" "bashunit is working" }
Finally, run the bashunit executable:
bash./lib/bashunit ./tests
If everything works correctly, you should see an output similar to the following:
bashunit - 0.18.0 | Tests: ~1 Running tests/example_test.sh ✓ Passed: Bashunit is working 16 ms Tests: 1 passed, 1 total Assertions: 1 passed, 1 total All tests passed Time taken: 90 ms
Now you can start testing the functionalities of your own Bash scripts.
Next steps
Dive deeper into the documentation to discover the options provided by assertions, snapshots, test files, data providers and test doubles among many other features.