testMore - yet another framework for writing test scripts
Yep - but for Linux shell scripts
# Include module
. "./testMore.sh"
# Plan number of tests
testMore_tests=8
# Various ways to say "ok"
ok ($got eq $expected) $test_name;
is $got $expected $test_name;
isnt $got $expected $test_name;
# Rather than print STDERR "# here's what went wrong\n"
diag "here's what went wrong";
like $got "expected" $test_name;
unlike($got "expected $test_name;
Using simple test like:
This module is simply included and ready to use
The process is:
. "./testMore.sh"
dump_header
testMore_tests=
ok
. is
, isnt
, like
, unlike
done_testing
. "./testMore.sh"
. "./trim.sh"
dump_header
diag "NOTE! Test 1 + 5 are supposed to fail"
testMore_tests=8
note
note "Testing OK"
ok 0 "This is NOT OK"
ok 1 "This is OK"
diag
diag "Testing IS"
mix=" 123 456 "
got=`trim "$mix"`
is "${got}" "123 456" "Trim l+r\t[${got}]"
diag
diag "This should fail:"
#mix=" 123 456 "
got=`trim "$mix"`
isnt "${got}" " 123 456 " "Trim l+r\t[${got}]"
diag
note "Special cases"
#mix=" 123 456 "
got=`ltrim "$mix"`
is "${got}" "123 456 " "Trim l\t[${got}]"
#mix=" 123 456 "
got=`rtrim "$mix"`
diag "Got to fail: Wrong number of arguments"
ok "${got}" " 123 456" "Got to fail: Wrong number of arguments"
diag "Like it - or not"
like "abcdefg" "bcd" "bcd in abcdefg"
unlike "abcdefg" "bfd" "bfd NOT in abcdefg"
#dump_stack
done_testing