deb-subunit/c
Jelmer Vernooij de954149f8 Force flush of writes to stdout in c/tests/test_child. 2010-12-09 01:26:18 +01:00
..
include/subunit Add subunit_progress() function to child interface. 2010-09-28 14:28:34 +02:00
lib Add subunit_progress() function to child interface. 2010-09-28 14:28:34 +02:00
tests Force flush of writes to stdout in c/tests/test_child. 2010-12-09 01:26:18 +01:00
README Apply trivial doc fix from Brad Hards for c/README. 2010-02-20 08:57:39 +11:00
check-subunit-0.9.3.patch Add patch for check. 2006-04-15 20:11:20 +10:00
check-subunit-0.9.5.patch Update the check patch to be more accceptable to upstream, include documentation, and apply to check 0.9.5. 2007-04-21 17:10:18 +10:00
check-subunit-0.9.6.patch Fix the updated check 0.9.6 patch to pass selftest. 2009-03-28 19:39:25 +11:00

README

#
#  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'