CuTest: C Unit Testing Framework
Overview
CuTest is a unit testing library for the C language. It can be
used to do Extreme Programming and Test-First Development in the
C language. It's a fun and cute library that will make your
programming fun and productive.
Benefits
- Lower Defects. The tests ensure that your code keeps working
as you make small changes in it. - Faster Debugging. The tests tell you which subroutine is
broken. You avoid spending hours trying to figure out what's
broken. - Development Speed. You trust your old code and can keep
adding to it without worrying about bad interactions. If there is
a bad interaction the tests will catch it. - Permanent Bug Fixes. If every time a bug is reported you
write a quick test, you will guarantee that the bug never
reappears again. - Fun. As your bug count drops you will begin to enjoy
programming like you've never done before. Running the tests
every few minutes and seeing them pass feels good.
Features
- Small. Consists of a single .c and .h file.
- Easy to Deploy. Just drop the two files into your source
tree. - Highly Portable. Works with all major compilers on Windows
(Microsoft, Borland), Linux, Unix, PalmOS. - Open Source. You can extend it to add more functionality.
The source can be invaluable if you are trying to trace a test
failure. - Cuteness. Of all the testing frameworks CuTest has the
cutest name :-)
Licensing
CuTest is distributed under the zlib/libpng
license. See license.txt in the distribution for text of license. The
intent of the license is to:
- Keep the license as simple as possible
- Encourage the use of CuTest in both free and commercial applications and libraries
- Keep the source code together
- Give credit to the CuTest contributors for their work
If you find CuTest useful we would like to hear about it.
Getting Started
For a detailed tutorial see README in the distribution. This shows you how
to organize your tests and how to autogenerate the AllTests.c file from your
source files.
To add unit testing to your C code the only files you need
are CuTest.c and CuTest.h.
CuTestTest.c and AllTests.c have been included to provide an
example of how to write unit tests and then how to aggregate them
into suites and into a single AllTests.c file. Suites allow you
to put unit tests for different parts of your code in different
files. AllTests.c combines all the suites and runs them.
You should not have to look inside CuTest.c. Looking in
CuTestTest.c (for example usage) should be sufficient.
After downloading the sources, run your compiler to create an
executable called AllTests.exe. For example, if you are using
Windows you would type:
cl AllTests.c CuTest.c CuTestTest.c AllTests.exe
This will run all the unit tests associated with CuTest and
print the output on the console.
For more details on how to use the library look at the README file included
with the distribution.
Contribute
We hope you CuTest saves you time and helps you produce high quality
software.
If you find CuTest useful, let us know. Tell us what platform you are using
it on (Windows, Linux, etc), and what kinds of applications you are using it
with.
If you would like to contribute documentation or tutorials to this project
please send e-mail.