summaryrefslogtreecommitdiff
path: root/lib/subunit/c/README
blob: b62fd453950bf94351a22c054da922c9e6373067 (plain)
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
#
#  subunit C bindings.
#  Copyright (C) 2006  Robert Collins <robertc@robertcollins.net>
#
#  Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
#  license at the users choice. A copy of both licenses are available in the
#  project source as Apache-2.0 and BSD. You may not use this file except in
#  compliance with one of these two licences.
#  
#  Unless required by applicable law or agreed to in writing, software
#  distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
#  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
#  license you chose for the specific language governing permissions and
#  limitations under that license.

This subtree contains an implementation of the subunit child protocol.
Currently I have no plans to write a test runner in C, so I have not written
an implementation of the parent protocol. [but will happily accept patches].
This implementation is built using SCons and tested via 'check'.
See the tests/ directory for the test programs.
You can use `make check` or `scons check` to run the tests. 

The C protocol consists of four functions which you can use to output test
metadata trivially. See lib/subunit_child.[ch] for details.

However, this is not a test runner - subunit provides no support for [for
instance] managing assertions, cleaning up on errors etc. You can look at
'check' (http://check.sourceforge.net/) or
'gunit' (https://garage.maemo.org/projects/gunit) for C unit test
frameworks. 
There is a patch for 'check' (check-subunit-*.patch) in this source tree.
Its also available as request ID #1470750 in the sourceforge request tracker
http://sourceforge.net/tracker/index.php. The 'check' developers have indicated
they will merge this during the current release cycle.

If you are a test environment maintainer - either homegrown, or 'check' or
'gunit' or some other, you will to know how the subunit calls should be used.
Here is what a manually written test using the bindings might look like:


void
a_test(void) {
  int result;
  subunit_test_start("test name");
  # determine if test passes or fails
  result = SOME_VALUE;
  if (!result) {
    subunit_test_pass("test name");
  } else {
    subunit_test_fail("test name",
      "Something went wrong running something:\n"
      "exited with result: '%s'", result);
  }
}

Which when run with a subunit test runner will generate something like:
test name ... ok

on success, and:

test name ... FAIL

======================================================================
FAIL: test name
----------------------------------------------------------------------
RemoteError:
Something went wrong running something:
exited with result: '1'