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:

  • A 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.