Fun programming with bash and writing tests
A testing example for bash scripts
Author: Anderson Santos
Built with ❤︎ by
Anderson Santos and
contributors
- Command parsing
- Parse commands in different orders
- Check for required commands
- Parse commands separated by space
- Testing
- Generates code coverage
- Runs linter and checker
- Build
- Show elapsed time
- Fail if the coverage is bellow some threshold
- Special methods for logging
- CI
- Configured to work with travis
- Cache the docker images
- Detects if it is building from travis to generate coveralls results
- Testing Examples:
- Table testing
- Functional and unit tests
- Combination of parameters validation
- src: Script source files
- tests: The test files
- build.sh: The build script to run the tests
Structure:
project/
├── src/
├── test/
│ │── functional-tests.html
│ │── unit-tests.html
└── build.sh
Download it; fork or clone it
Just call:
./build.sh
It will execute all tests inside test dir and generate a coverage report at: test/coverage
folder
- Shunit2 - The bash testing framework
- kcov - Code coverage tool for compiled programs, Python and Bash which uses debugging information to collect and report data without special compilation options
- shellcheck - Bash checker
- Anderson Santos - Initial work - supergarotinho
See also the list of contributors who participated in this project.
This project is licensed under the BSD-3 License - see the LICENSE.md file for details
We use koalaman/shellcheck
image to run shellcheck