- Repository: https://github.com/arapower/stl
- README
- README: Japanese
stl (Shell Testing Library) is a testing library designed to simplify writing tests for shell scripts. It aims to use POSIX shell-compatible syntax as much as possible to ensure wide compatibility across various environments.
To create a directory for stl, execute the following command in the desired location.
curl -fsSL https://raw.githubusercontent.com/arapower/stl/main/mod/setup_stl.sh | sh
Or,
wget -O - https://raw.githubusercontent.com/arapower/stl/main/mod/setup_stl.sh | sh
Simply delete the stl
directory created by the installation command.
- Save test code in the
code
directory - Run the
start_stl.sh
script - View the execution results
Test code is structured as follows.
setup() {
# Preparation before the test
}
teardown() {
# Cleanup after the test
}
stl_test_case() {
# Test case
}
Here's a simple test example.
- Test target:
app/sample.sh
#!/bin/sh
echo "$1"
- Test code:
stl/code/sample.sh
setup() {
target_script="${PRJ_ROOT_DIR}/app/sample.sh"
}
teardown() {
:
}
stl_echo_test() {
assert_equal "\"${target_script}\" hello" "hello"
}
$ ./stl/start_stl.sh
[OK] sample.sh:10 stl_echo_test
- User Manual: Basic usage including naming conventions for test case functions
- Reference: Assertion Functions: Detailed explanation of assertion functions
- Design and Implementation of stl (Shell Testing Library): Overview of stl's design philosophy, structure, and implementation features
- Advanced Practical Guide: Advanced usage and practical techniques
- Glossary: Definitions of key terms used in stl