O'Reilly logo
  • Preetham Nanjappa thinks this is interesting:

A test harness has a few features that beat the typical homemade test macro:

  • You need to test the failures. If a function is supposed to abort or exit with an error message, you need a facility to test that the program actually exited when you expected it to.

  • Each test is kept separate, so you don’t have to worry that test 3 affected the outcome of test 4. If you want to make sure the two procedures don’t interact badly, run them in sequence as an integration test after running them separately.

  • You probably need to build some data structures before you can run your tests. Setting up the scene for a test sometimes takes a good amount of work, so it would be ...


Cover of 21st Century C, 2nd Edition