News for hackers. Stuff that matters.

Unit testing for C?

Being new to C in general, I haven't yet had to deal with large project structures. However, that's about to change. What would you recommend as a somewhat robust testing framework?

I'm not too picky, just looking for some reviews/experiences/hints. Thanks!

( 3 comments | 9 points | on HN )
Re:Unit testing for C? by stevekemp on Wednesday December 11, 2013 @05:12AM (#6886846)
The last time I wrote a C project I used "cunit":

http://cunit.sourceforge.net/

It was nice that I could both compile the test-cases as standalone executables, and also build them into my main application. Running "./foo --tests" to run the test-suite post-installation was very nice for getting user-feedback.

There are a few frameworks for test-suites for C, and I looked around a fair bit before picking this one. Whether it suits you is an open question, but if you're not sold on it feel free to browse:

http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks...

Re:Unit testing for C? by carlmro on Wednesday December 11, 2013 @05:29AM (#6886896)
I found this presentation on test-driven development in C using assert and stdbool interesting:

http://www.slideshare.net/amritayan/test-driven-development-....

It shows that you can accomplish quite a lot without a standalone testing framework. Good luck with writing C!

Re:Unit testing for C? by bfrog on Tuesday December 17, 2013 @03:25PM (#6923676)
libcheck is nice

it forks off every test so its fast and failures like segfaults are really just test failures.