This may seem like a silly question, but how do C programmers (assume
gcc/linux for now) do behavior-driven/test-driven development? Aside
from the obvious cheat (using RSpec to compile, link and execute the C
code) are there tools in C to do this?
I've tried a bunch of the unit test frameworks for C++ but never liked
any of them, so I rolled my own. A test suite is in its own file and
looks like this:
TESTSUITE(MyTestSuite)
SETUP(MyTestSuite)
{
// put code here
}
TEARDOWN(MyTestSuite)
{
// put code here
}
TESTCASE(test_name)
{
ASSERT_EQUAL(true, true);
}
Though there's a lot that this model can't do (e.g. there's no
inheritance relationship between test suites), a big advantage here is
that you don't have to specify the test case names in two places as with
most other frameworks (once for the function definition and again to add
the function to the test suite). I'd worry that I'm reinventing the
wheel, except it only took an hour or so to implement.
It's included as part of Rice (rice.rubyforge.org).
Paul