Provided by: shunit2_2.1.8-4_all 

Name
shunit2 - unit test framework for shell scripts
Synopsis
shunit2 unit-file
Description
shUnit2 is an xUnit unit test framework for Bourne-based shell scripts, and is designed to work in a
similar manner to JUnit, PyUnit, and so forth. If you have ever had the desire to write a unit test for
a shell script, shUnit2 can do the job.
You can either run shunit2 directly from the command line and specify the unit file unit-file or directly
source the shunit2 executable.
If you directly execute shunit2 and don't specify unit-file, shUnit2 assumes an empty test file and will
return without an error message.
Options
shunit2 does not support any command-line options at all. You can either source shunit2 with the shell's
. (“dot”) built-in to execute your unit tests or directly run shunit2 as a command with unit-file as a
parameter.
Example
The following simple script tests whether 1 equals 1.
#! /bin/sh
testEquality()
{
assertEquals 1 1
}
# load shunit2
. shunit2
The above example assumes this is executed on the machine where shunit2 is available as an executable
command found in the path specified by the environment variable $PATH. You can alternatively copy a
/usr/bin/shunit2 file from this machine to path/to/shunit2 in the target source tree and use it in the
target build environment as follows.
#! /bin/sh
testEquality()
{
assertEquals 1 1
}
# load shunit2
. path/to/shunit2
The following is a shell session transcript showing how to write the same test as above and execute it
directly.
$ cat > test_equality.sh <<EOF
testEquality()
{
assertEquals 1 1
}
EOF
$ shunit2 test_equality.sh
Note that shunit2 is not sourced in this example.
More sophisticated examples can be found in file:///usr/share/doc/shunit2/examples/.
Authors
shUnit2 was written by Kate Ward. This man page was originally written by Ulrich Dangel.
See also
For more information, see the shUnit2 GitHub project, or have a look at the installed documentation.
shunit2 2.1.8 2020-03-29 shunit2(1)