What is Test harness/ Unit test framework tools in software testing?

These tools are mostly used by developers. These two types of tool are grouped together because they are variants of the type of support needed by developers when testing individual components or units of software.

A test harness provides stubs and drivers, which are small programs that interact with the software under test (e.g. for testing middleware and embedded software). Some unit test framework tools provide support for object-oriented software, others for other development paradigms.

Unit test frameworks can be used in agile development to automate  the tests parallely with development. Both types of tool enable the developer to test, identify and localize any defects. The stubs and drivers supply any information needed by the software being tested (e.g. an input given by the user) and also receive any information sent by the software (e.g. a value to be displayed on a screen). Stubs may also be referred to as ‘mock objects’.

There are many ‘xUnit’ tools for different programming languages, e.g. JUnit for Java, NUnit for .Net applications, etc. There are both commercial tools and also open-source (i.e. free) tools. Unit test framework tools are very similar to test execution tools, since they provide facilities such as the ability to store test cases and monitor whether tests pass or fail, for example.

The main difference is that there is no capture/playback facility and they tend to be used at a lower level, i.e. for component or component integration testing, rather than for system or acceptance testing.

Features or characteristics of test harnesses and unit test framework are:

  • To supply inputs to the software being tested;
  • To receive outputs generated by the software being tested;
  • To execute a set of tests within the framework or using the test harness;
  • To record the pass/fail results of each test (framework tools);
  • To store tests (framework tools);
  • Provide support for debugging (framework tools);
  • To do coverage measurement at code level (framework tools).