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.


  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.

  2. How about doing it in python using something like ?

  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.

  4. may be of interest for you.

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

  6. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.