The most scalable way to write unit tests in C is using a unit testing framework, such as: CppUTest. Unity. Google Test.
A Unit Testing Framework for CCUnit is a lightweight system for writing, administering, and running unit tests in C. It provides C programmers a basic testing functionality with a flexible variety of user interfaces.
Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. This testing methodology is done during the development process by the software developers and sometimes QA staff.
Unit testing helps developers to test their code written whether it meets design & requirements and behaves as expected before delivering to QA testing. This will help to identify problems at early stages of the development even though it can't be replaced with integration testing & performance testing.
Applying unit tests to legacy code was the very reason Working Effectively with Legacy Code was written. Michael Feathers is the author - as mentioned in other answers, he was involved in the creation of both CppUnit and CppUnitLite.
Google recently released their own library for unit testing C++ apps, called Google Test.
Project on Google Code
Check out an excellent comparison between several available suites. The author of that article later developed UnitTest++.
What I particularly like about it (apart from the fact that it handles exceptions etc. well) is that there is a very limited amount of 'administration' around the test cases and test fixtures definition.
Boost has a Testing library which contains support for unit testing. It might be worth checking out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With