summaryrefslogtreecommitdiff
path: root/test/libtest/lib/test.3
blob: e170c181595acdb83b3c4a6c8e19132256128624 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
.\" Copyright (c) 2018,2019 Joseph Koshy.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" This software is provided by Joseph Koshy ``as is'' and
.\" any express or implied warranties, including, but not limited to, the
.\" implied warranties of merchantability and fitness for a particular purpose
.\" are disclaimed.  in no event shall Joseph Koshy be liable
.\" for any direct, indirect, incidental, special, exemplary, or consequential
.\" damages (including, but not limited to, procurement of substitute goods
.\" or services; loss of use, data, or profits; or business interruption)
.\" however caused and on any theory of liability, whether in contract, strict
.\" liability, or tort (including negligence or otherwise) arising in any way
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $Id$
.\"
.Dd January 21, 2019
.Dt TEST 3
.Os
.Sh NAME
.Nm test
.Nd API for writing tests
.Sh LIBRARY
.Lb libtest
.Sh SYNOPSIS
.In test.h
.Ft enum test_case_status
.Fn test_case_setup "test_case_state *state"
.Ft enum test_case_status
.Fn test_case_teardown "test_case_state state"
.Ft enum test_result
.Fn test_function "test_case_state state"
.Vt "const char"
.Va test_description [] ;
.Vt "const char *"
.Va test_tags [] ;
.Vt "const char"
.Va test_case_description [] ;
.Vt "const char *"
.Va test_case_tags [] ;
.Sh DESCRIPTION
The
.Lb libtest
implements an API for writing tests.
.Ss Concepts
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:
.Bl -bullet -compact
.It
An optional human-readable test description.
.It
An optional set of tags.
Tags are used to select or deselect specific tests in a run.
.El
.Pp
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:
.Bl -bullet -compact
.It
An optional human-readable test case description.
.It
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.
.It
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.
.It
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.
.El
.Pp
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.
.Ss Scaffolding Generation
The
.Xr make-test-scaffolding 1
script will generate the scaffolding needed to produce a test executable
from object files containing symbols following its naming conventions.
.Sh SEE ALSO
.Xr make-test-scaffolding 1
.Sh AUTHORS
The
.Lb libtest
was written by
.An Joseph Koshy Aq Mt jkoshy@users.sourceforge.net .