Test harness code generation

The development of our new unit testing tool has reached its first milestone with the completion of the test harness generator.

The generator takes an XML file containing the test case definitions and automatically generates C or C++ source code for the test harness. Some of the C++ features are:

  • Objects can be instantiated (on the heap or the stack), methods called, and objects deleted.
  • Exceptions can be tested (including those thrown by constructors), and unexpected exceptions are trapped.
  • The output of the test harness is easily configured to suit the target hardware.
  • The test context is accessable from user stub-code.
  • Whitebox testing is implemented by adding a friend to the class being tested.
  • Exception handling can be disabled to make the generated code compatible with Embedded C++ compilers.

Permanent link to this article: http://www.apollo-systems.co.uk/dev/2011/test-harness-code-generation/