Test harness

A test harness is the software scaffolding that automates the execution of tests against a unit of code or a system, and reports the results. It wraps the code under test so it can be exercised in isolation, repeatably, and without manual intervention.

A test harness typically combines:

  • Test execution engine (or test runner): The framework that discovers, runs, and reports on tests.
  • Test scripts: The individual test cases and their assertions.
  • Fixtures: The setup and teardown that put the system into a known state before each test.
  • Stubs, drivers, and mocks: Stand-ins for collaborators that are absent, slow, or non-deterministic, so the unit under test can run in isolation.

By feeding controlled inputs to the code, invoking it, and capturing its outputs for comparison against expected results, a test harness makes testing automated and reproducible.

The term is the origin of the "harness" metaphor in agent harness engineering. In both cases the harness is the rig that wraps the thing being run – supplying its inputs, exercising it, and capturing its outputs – rather than the thing itself.


See also