Files
deb-subunit/c

#
#  subunit C bindings.
#  Copyright (C) 2006  Robert Collins <robertc@robertcollins.net>
#
#  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
#  (at your option) 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.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

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 build 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. I plan to write a
'check' runner which uses these bindings to provide subunit output, at which
point creating a trivial python test_c.py script which uses the pyunit gui to
will be added to me todo list.

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. I plan to write ui layers for both of these that use the subunit
bindings for reporting. There is a patch for 'check'
(check-subunit-0.9.3.patch, and check-subunit-0.9.5.patch) in this source tree.
Its also available as request ID #1470750 in the sourceforge request tracker
http://sourceforge.net/tracker/index.php.

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_failf("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'