Adding a bunch of function to a big application (a 4GL) that was developed long ago and over the course of 10 years (1987 - 1997) is a risky business. Particularly when the only extant testing code is written in the 4GL – equivalent to only being able to test an HTML browser by getting it to process HTML.
I've certainly learned a lot since I took on my first product development job. One of the practices I'm still learning is good unit testing. I've learned to think in terms of the JUnit unit testing framework. Such a framework is important to focus the testing code on testing instead of housekeeping and to define standard reports. There are several unit testing frameworks for C listed on OpenSourceTesting.org.
The following list contains the subset of the test frameworks that I've considered for my project. As noted below, I've picked up the Cgreen framework with good results.
- Boost.Test
- This framework is in active use, but it's primarily used for C++ applications. The API looks simple enough that it could be reasonably used to test C functions.
- C Unit Test System
- Defunct project – there's a note on the sourceforge project forum from 2003 asking if there are any users.
- Cgreen
- Unit testing strictly for C with a facility for mocking functions.
- C Unit
- Abandoned project. No response to inquiries or code updates since 2006.
- CuTest
- A very simple implementation of unit test framework. Some activity on the project. No documentation found.
- RCUNIT
- Abandoned project. No activity since 0.9 in 2006
- Simple C Test
- Abandoned project. No activity since 2005. Some documentation is provided.
- Test soon
- Abandoned project. No activity since 2007. Seems to focus on flexibility to structure tests and not so much on enabling easy authoring.
- TUT test framework
- Interesting framework in C++ compiled into each test suite. Not clear how failures should be detected, not designed to automatically recover from faults (SEGV) so further test cases can run.
- unit--
- Abandoned project. No activity since 2006.
- Unity & CMock
- Nice looking unit test and mock tools for C targeting embedded systems developers. Cmock requires Ruby and Rake.
The other tools listed were apparently only for C++ or objective C.
After some examination and experimentation, the Cgreen package seems to be the best fit. The mock function capability is a useful stand-in for the mock objects one would use for an object-oriented environment.
No comments:
Post a Comment