Functions |
function | _shtap_cleanup () |
| Cleaning up after execution of tests and see if plan was fulfilled.
|
function | _shtap_die (in reason) |
| Abort test execution.
|
function | _shtap_equals (in result, in expected) |
| Compare actual and expected result.
|
function | _shtap_exit () |
| Terminate execution of tests.
|
function | _shtap_exit_status () |
| Calculate exit status indicating number of failed or extra tests.
|
function | _shtap_is_diag (in result, in expected) |
| Diagnostic message for is().
|
function | _shtap_print_plan () |
| Print plan.
|
function | diag (in msg) |
| Print diagnostic message.
|
function | fail () |
| Fail in any case and print reason.
|
function | is (in result, in expected, in name) |
| Test whether a given result is equal to the expected result.
|
function | isnt (in result, in expected, in name) |
| Test whether a given result is not equal the expected result.
|
function | like (in result, in pattern, in name) |
| Test whether a given result matches an expected pattern.
|
function | ok (in expression, in name) |
| Evaluate test expression and fail if it does not evaluate to 0 or check return value of function.
|
function | okx (in command) |
| Execute command and check return value.
|
function | pass () |
| Pass in any case and print reason.
|
function | plan_no_plan () |
| Choose not to plan number of tests in advance.
|
function | plan_skip_all () |
| Plan to skip all tests.
|
function | plan_tests () |
| Plan a certain number of tests and stick to it.
|
function | SHTAP_BAIL_OUT (in reason) |
| Bail out.
|
function | skip (in condition, in reason, in n) |
| Skip tests under a certain condition.
|
function | unlike (in result, in pattern, in name) |
| Test whether a given result does not match an expected pattern.
|
Unit testing framework for BASH based on the Test Anything Protocol.
- Author:
- Patrick LeBoutillier <patl at cpan.org>
- Note:
- This file is a copy of the tap-functions file which is part of the JTap project (http://svn.solucorp.qc.ca/repos/solucorp/JTap/trunk/). The original implementation has been modified by Andreas Schuh as part of the BASIS project at SBIA.
Plan:
Test:
Skip:
skip [CONDITION] [REASON] [NB_TESTS=1]
skip $feature_not_present "feature not present" 2 ||
{
is $a "a"
is $b "b"
}
Specify TODO mode by setting the TODO variable:
TODO="not implemented yet"
ok $result "some not implemented test"
unset TODO
Other:
Example:
#! /usr/bin/env bash
source shtap.sh
plan_tests 7
# test identity
{
me=${USER}
is ${USER} ${me} "I am myself"
like ${HOME} ${me} "My home is mine"
like "`id`" ${me} "My id matches myself"
}
# test ls
{
ls ${HOME} 1>&2
ok $? "ls ${HOME}"
# same thing using okx shortcut
okx ls ${HOME}
}
# test only for root
{
[[ "`id -u`" != "0" ]]
i_am_not_root=$?
skip ${i_am_not_root} "Must be root" ||
{
okx ls /root
}
}
# test TODO
{
TODO="figure out how to become root..."
okx [ "$HOME" == "/root" ]
unset TODO
}
Copyright (c) Patrick LeBoutillier.
Copyright (c) 2011, University of Pennsylvania.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- See also:
- http://testanything.org/wiki/index.php/Tap-functions
Contact: SBIA Group <sbia-software at uphs.upenn.edu>
Definition in file shtap.sh.