A test harness is everything around the code under test that lets you run it and judge the result: the driver that calls it, stand-ins for its dependencies, the test data, the runner and the reporting. You pay for one whenever tests need more than the product itself. An AI agent needs one that also contains its side effects.
What does a test harness contain?
In everyday use, a harness answers the same questions. This is the working definition from practice, not a quote from a standard. How do you call the code? What stands in for the things it depends on? Where does the data come from? Who runs the cases and writes the report?
| Part | What it does in an ordinary suite | What it becomes around an AI agent |
|---|---|---|
| Driver | Calls the code under test, such as a function, an API or a browser | Sends a task to the agent and collects its answer |
| Stub or fake | Replaces a slow or unavailable dependency | A sandboxed copy of each tool the agent may call |
| Fixture and test data | Sets up the state a test starts from | The task set, plus the files and accounts the agent starts with |
| Runner | Executes cases and isolates them | Executes tasks, often several times each |
| Assertion | Decides pass or fail from a known answer | A scorer: a rule, a check on the end state or a judge model |
| Reporting | Shows what failed and why | A trace of every step the agent took |
The word is used for two things. Some teams mean a runnable setup for one product. Others mean a library, such as testharness.js, which the web-platform-tests documentation describes as the framework its JavaScript tests are written in. Harness, the CI/CD company, is a third meaning and has nothing to do with either.
Do you need to build a harness, or does your framework already give you one?
Usually your framework gives you most of it. The Playwright documentation says fixtures “are used to establish the environment for each test, giving the test everything it needs and nothing else.” The pytest documentation says fixtures define “the steps and data that constitute the arrange phase of a test.” On the Java side, the JUnit User Guide describes the JUnit Platform as “a foundation for launching testing frameworks on the JVM.” So the runner, setup and isolation come ready-made.
Build something extra only when the product needs it. That is a judgement call, and it usually comes down to three cases:
- A dependency is paid per call, slow or not built yet, so you need a fake.
- Tests need data that no framework creates, such as accounts in a state that takes days to reach.
- Several teams run the same checks and each has copied the setup.
If none of these applies, adding a harness layer is cost without a return. Ask your lead which of the three they have, and ask who maintains the answer. For the framework side of this decision, see our comparison of unit test tools. If the harness has to run in CI, see our guide to building a QA automation pipeline.
What does a harness for an AI agent need that an ordinary one does not?
An agent acts. It calls tools, changes files and sends messages. A harness that lets it do that on live systems is a risk, so the first need is containment: each tool runs against a sandbox or a fake, and nothing leaves it. Inspect, an evaluation framework from the UK AI Security Institute and Meridian Labs, lists “a sandboxing system that supports running untrusted model code in Docker, Kubernetes, Modal, Proxmox, Vagrant, and other systems” among its core features.
The second need is repeat runs. The same task can succeed on one run and fail on the next, so one pass proves little. The third is a trace of every step, because a wrong final answer is hard to fix without seeing the path to it. Inspect describes its building blocks as “datasets, agents, tools, and scorers”, which maps onto the table above.
Our guides to testing AI agents and testing an MCP server go through the cases, and Zapple.Tech builds harnesses as part of the AI agent testing work.
What does a harness not solve?
A harness runs and records. It does not decide what a correct result is. That comes from your success criteria and a labelled set of examples, and someone has to write and keep them. A harness with weak scorers produces tidy reports about the wrong things. It also does not cover what the sandbox leaves out: a fake that drifts from the real service passes tests the real one would fail.
What does Zapple.Tech do about it?
If you are not sure whether your tests need a harness of their own, start with the evidence. Zapple.Tech starts with a one-week QA audit of one product area. It looks at its tests, pipeline and release process, and ends in a written report on what is at risk and what to fix first, plus a pilot plan you can run with Zapple.Tech or without it. Read more on the QA audit and assessment page.
Tell us about your setup in the form below.
How does test harness relate to other terms?
- LLM evaluation
LLM evaluation is the practice of measuring how a language-model feature or agent behaves on a defined set of tasks, using written success criteria and scores. It does not by itself show the feature is correct. Our AI agent testing builds a task set, a measured baseline and a suite that scores each model, prompt or tool change.
- AI testing
AI testing is the testing of software that uses machine learning or large language models, whose outputs vary and cannot always be checked against one fixed answer. Our AI testing services build an evaluation dataset for your AI feature, a baseline of how it behaves today, and checks that run in your CI.
- RAG evaluation
RAG evaluation measures a retrieval-augmented generation system in two parts: whether the search step returned the right passages, and whether the answer built from them is supported and useful. Scoring the two separately tells you which one to fix. You need a labelled question set before any score means something.
- LLM as a judge
LLM as a judge means using one language model to grade the output of another against a rubric, so a team can score thousands of answers unread by people. It is fast and flexible, but the judge makes its own errors. Trust its score only after you compare it with human labels, and check hard rules without a model.
Sources
- Playwright documentation, Fixtures (current docs) (read 5 December 2026)
- pytest documentation, About fixtures (current docs) (read 5 December 2026)
- web-platform-tests documentation, JavaScript tests (testharness.js) (read 5 December 2026)
- JUnit User Guide, Overview (6.1.3) (read 6 December 2026)
- Inspect, UK AI Security Institute and Meridian Labs (current docs) (read 5 December 2026)