Skip to content

arapower/stl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stl

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.

Installation

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

Uninstallation

Simply delete the stl directory created by the installation command.

Basic Usage

  1. Save test code in the code directory
  2. Run the start_stl.sh script
  3. 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
}

Test Example

Here's a simple test example.

Code to be Tested

  • Test target: app/sample.sh
#!/bin/sh
echo "$1"

Test Code

  • 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"
}

Test Execution Example

$ ./stl/start_stl.sh
[OK] sample.sh:10 stl_echo_test

Related Documents

About

Test library for shell script.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published