test —
API for
writing tests
library “libtest”
#include
<test.h>
enum test_case_status
test_case_setup(
test_case_state
*state);
enum test_case_status
test_case_teardown(
test_case_state
state);
enum test_result
test_function(
test_case_state
state);
const char
test_description [];
const char *
test_tags [];
const char
test_case_description [];
const char *
test_case_tags [];
The
library “libtest”
implements an API for writing tests.
Tests are implemented using test functions, where each test function verifies a
specific assertion about the system being tested. Test functions are
associated with the following:
- An optional human-readable test description.
- An optional set of tags. Tags are used to select or
deselect specific tests in a run.
Test functions are further grouped into test cases, where a test case contains a
logical group of assertions about the system under test. Test cases are
associated the following:
- An optional human-readable test case description.
- An optional test case set up function. If specified,
this set up function would be invoked prior to any test function contained
in the test case. The set up function can allocate and initialize
test-specific state, to be passed to test functions. If no set up function
is specified for the test case, a default (no-op) function will be
supplied.
- An optional test case tear down function. The tear down
function will be invoked after all test functions have been invoked. It
would be responsible for deallocating any resources that its corresponding
set up function had allocated. If no tear down function is specified for a
test case, a default no-op function will be supplied.
- An optional set of tags for the test case. These tags
are used to select or delect specific test cases in a given test run.
One or more test cases would be linked with a test driver to form a test
executable. The default test driver supplied allows the test cases and
specific tests within the executable to be specified on the command line.
The
make-test-scaffolding(1)
script will generate the scaffolding needed to produce a test executable from
object files containing symbols following its naming conventions.
make-test-scaffolding(1)
The
library “libtest” was
written by
Joseph Koshy
<
jkoshy@users.sourceforge.net>.