views:

264

answers:

5

I'm starting a new project and decided that I should give this unit testing thing that everybody keeps talking about a try.

The project is a set of C libraries (so no UI or user interaction testing is necessary) and aimed at being cross platform, with Linux, FreeBSD and Windows being my first priority and OS X planned once the first release is out the door (assuming I can get a hold of a machine running OS X to test on).

Does anybody have any experience or recommendations for a good C unit testing framework that easily works across multiple platforms?

+1  A: 

Back when I was writing C code all of my unit tests were ad-hoc, no framework involved, so I can't recommend any of these, but you may want to look at the list of C/C++ unit testing tools at http://www.opensourcetesting.org/unit_c.php.

tvanfosson
+1  A: 

I used to use CUnit which I liked. Also google have open sourced their C++ unit testing framework.

Andrew Barrett
A: 

I've grown quite partial to tap (scroll down near the bottom) because its easy to drop in place. It stands for "test anything protocol". I don't think you'd hit many portability issues with it if using compilers released in the last 5 years, but I've only tried it with gcc / glibc.

Tim Post
The link to the description of TAP appears to be broken. Is there another one?
Pete Kirkham
You can grab the code there, the full description can be found here:http://en.wikipedia.org/wiki/Test_Anything_Protocol
Tim Post
+1  A: 

I started with minunit then evolved it to suit my requirements. Rather than having support for test suites from a testing framework, I just use make to build and run different executables, each with a dozen or so related tests in them. So now I've about 250 lines of macros, mainly for printing out different types or doing string or memory comparison, and that's enough for now.

Pete Kirkham
A: 

Hi, I use my own unit testing framework CUnitWin32 for embedded C stuff. My host dev environment is Win32 so the framework that is available on-line is for Windows only. However, I did port it to Linux as well, so if the framework works for you, drop me a comment here and we'll work out a way to get your the Linux version.

D

Dushara
Thanks for the offer. I'll take a look at it and let you know.