Wednesday, October 14, 2009

Unit Testing in C

I haven't written new C code since the turn of the millennium. Since then it's been almost all Java and Python. Along with Java and Python come JUnit and Python's unittest module.

I've grown completely dependent on unit testing.

I'm looking at some C code, and I want a unit testing framework. For pure C, I can find things like CuTest and CUnit. The documentation makes them look kind of shabby. Until I remembered what a simplistic language C is. Considering what they're working with, they're actually very cool.

I found a helpful posting on C++ unit testing tools. It provided some insight into C++. But this application is pure C.

I'm interested in replacing the shell script in CuTest with a Python application that does the same basic job. That's -- perhaps -- a low-value add-on. Perhaps I should look at CUnit and stay away from replacing the CuTest shell script with something a bit easier to maintain.

5 comments:

  1. Have you considered Cgreen? A few friends have recommended it for C unit testing, but I haven't had the chance to try it yet.

    ReplyDelete
  2. How about doing it in python using something like http://www.swig.org/ ?

    ReplyDelete
  3. I have found it easier to write unit tests in C than to use Swig.

    I use CUnit. It doesn't do much compared to libraries available in Python, but it is reliable. It is simple enough to keep everything you need to know in your head.

    ReplyDelete
  4. http://code.google.com/p/test-dept/ may be of interest for you.

    ReplyDelete
  5. If you write itr correctly no need for Cunit...

    ReplyDelete