tags:

views:

353

answers:

5

I am a professional web developer and therefore I'm used to using very high-level scripting languages and testing tools. I've recently been working, personally, more with C and writing many C programs for unix-based systems to do various tasks.

However, I still haven't gotten into a good groove for unit testing this code and I was wondering what tools C programmers use to create automated tests to verify code.

+1  A: 

Are you testing strictly C code, or can you mix in some C++? If C++ is OK, cppunit is probably worth checking out. If you are testing a library, you can simply link you library into your unit test application. If you are testing an app, you will probably have to create a library, and then link it into both your app and the unit test app.

mch
+1  A: 

I had this question once and discovered CUnit. I only used it for a small project, but it seemed alright. Not nearly as convenient as JUnit or NUnit that I am used to though! For C++ projects I use cppunit which works quite well.

Jeremy
+1  A: 

CUtest. It's really neat. Small, doesn't rely on a generator language, fast... what's not to like?

+2  A: 

See also this question: http://stackoverflow.com/questions/65820/unit-testing-c-code.

MattK
This was the kind of question I was looking for but the search wasn't really finding it. Thanks!
Mitchell
+1  A: 

If you only want a quick'n'dirty test mechanism, have a look at the assert macro, part of ANSI C.