Test functions are available for use within test code files. The following describes the behavior of each test function.
- Arguments
- 1: Command string to verify
- 2: Expected result
- Judgment
OK
if the result of executing argument 1 (standard output + standard error output) exactly matches argument 2
assert_both_equal "echo 'Hello, World!'" "Hello, World!"
- Arguments
- 1: Command string to verify
- 2: Expected result
- Judgment
OK
if the result of executing argument 1 (standard output + standard error output) does not exactly match argument 2
assert_both_not_equal "echo 'Hello, World!'" "Goodbye, World!"
- Arguments
- 1: Command string to verify
- 2: Expected result
- Judgment
OK
if the result of executing argument 1 (standard output) exactly matches argument 2
assert_equal "echo 'Hello'" "Hello"
- Arguments
- 1: Command string to verify
- 2: Expected result
- Judgment
OK
if the result of executing argument 1 (standard output) does not exactly match argument 2
assert_not_equal "echo 'Hello'" "World"
- Arguments
- 1: Command string to verify
- 2: Expected result
- Judgment
OK
if the result of executing argument 1 (standard error output) exactly matches argument 2
assert_error_equal "command_that_fails" "sh: line 1: command_that_fails: command not found"
- Arguments
- 1: Command string to verify
- 2: Expected result
- Judgment
OK
if the result of executing argument 1 (standard error output) does not exactly match argument 2
assert_error_not_equal "command_that_fails" "Different error message"
- Arguments
- 1: Command string to verify
- 2: Expected result (regular expression)
- Judgment
OK
if the result of executing argument 1 (standard output) contains the regular expression in argument 2
assert_match "echo 'Hello, World!'" "Hello.*World"
- Arguments
- 1: Command string to verify
- 2: Expected result (regular expression)
- Judgment
OK
if the result of executing argument 1 (standard output) does not contain the regular expression in argument 2
assert_not_match "echo 'Hello, World!'" "Goodbye"
- Arguments
- 1: Command string to verify
- 2: Expected result (regular expression)
- Judgment
OK
if the result of executing argument 1 (standard error output) contains the regular expression in argument 2
assert_error_match "command_that_fails" "command not found"
- Arguments
- 1: Command string to verify
- 2: Expected result (regular expression)
- Judgment
OK
if the result of executing argument 1 (standard error output) does not contain the regular expression in argument 2
assert_error_not_match "command_that_fails" "Different error.*"
- Arguments
- 1: Command string to verify
- 2: Path to the file containing the expected result
- Judgment
OK
if the result of executing argument 1 (standard output + standard error output) exactly matches the content of argument 2
expected=$(mktemp)
echo 'Expected output' > "${expected}"
assert_both_equal_file "echo 'Expected output'" "${expected}"
- Arguments
- 1: Command string to verify
- 2: Path to the file containing the expected result
- Judgment
OK
if the result of executing argument 1 (standard output + standard error output) does not exactly match the content of argument 2
unexpected=$(mktemp)
echo 'Unexpected output' > "${unexpected}"
assert_both_not_equal_file "echo 'Expected output'" "${unexpected}"
- Arguments
- 1: Command string to verify
- 2: Path to the file containing the expected result
- Judgment
OK
if the result of executing argument 1 (standard output) exactly matches the content of argument 2
expected=$(mktemp)
echo 'Expected output' > "${expected}"
assert_equal_file "cat ${expected}" "${expected}"
- Arguments
- 1: Command string to verify
- 2: Path to the file containing the expected result
- Judgment
OK
if the result of executing argument 1 (standard output) does not exactly match the content of argument 2
unexpected=$(mktemp)
echo 'Unexpected output' > "${unexpected}"
assert_not_equal_file "${target_script}" "${unexpected}"
- Arguments
- 1: Command string to verify
- 2: Path to the file containing the expected result
- Judgment
OK
if the result of executing argument 1 (standard error output) exactly matches the content of argument 2
expected_error=$(mktemp)
echo 'Expected error message' > "${expected_error}"
assert_error_equal_file "${target_script}" "${expected_error}"
- Arguments
- 1: Command string to verify
- 2: Path to the file containing the expected result
- Judgment
OK
if the result of executing argument 1 (standard error output) does not exactly match the content of argument 2
unexpected_error=$(mktemp)
echo 'Unexpected error message' > "${unexpected_error}"
assert_error_not_equal_file "command_that_fails" "${unexpected_error}"
- User Manual. Basic usage including naming conventions for test case functions
- Glossary: Definitions of key terms used in stl