How AI Is Changing Software Testing: Agents and Evals
Most writing about AI in testing is either breathless or dismissive. My view is more practical. AI has changed two things about the job, and both are worth understanding properly: who writes and maintains the tests, and what kind of systems we now have to test.
The first change is agents doing quality engineering work. GitHub Copilot, Claude Code, Cursor and similar coding agents draft tests, write step definitions, refactor fixtures, run suites and explain failures. The second is quality engineering of AI itself: more and more products include an LLM feature or an agent that calls tools, and those don't behave like a deterministic API. A single green run proves very little about them.
Together these make up what I think of as agentic quality engineering. This guide covers both halves: how I use agents on test code without losing control of what the tests check, and how I approach testing a feature whose output changes from run to run.
From Zero to Smarter API Automation with Node.js & Cucumber — Using AI, CI/CD, and Modern Tooling.
What AI is actually good at in test work
In practice, assistants and agents earn their place on work that's mechanical once the intent is clear:
- Boilerplate. Fixtures, API clients, step definitions for scenarios a human wrote, test file scaffolding.
- Breadth. Parametrised negative cases, boundary values, schema checks for every resource.
- Reading. Explaining an unfamiliar codebase or API, summarising a long CI log, finding which recent commit touched the failing area.
- Refactoring. Renaming, extracting helpers, migrating tests between library versions, with the suite as the safety net.
Where they're weak is the judgment at the start and the end: deciding what behaviour matters, and deciding whether a test really protects it. An agent will happily produce forty tests in a minute. Some will assert the wrong thing, and some will assert whatever the system returns today. Writing tests has become cheap; reviewing them has become the bottleneck.
Give the agent a contract, not a vague request
The quality of generated tests follows the quality of the input. "Write tests for the orders API" gets you guesses. A prompt that includes the spec, the expected statuses, the business rules and the existing conventions gets you tests you can review against something. I cover the wording in writing AI prompts that produce testable API assertions.
The strongest contract is a human-written specification the agent implements against: an OpenAPI document, acceptance criteria, or Gherkin scenarios. People decide what the system should do; the agent writes the code that checks it. That division of labour is the core of how I use AI on test suites, and it's why BDD-style specs have become more useful rather than less.
Standing rules go in the repository, not in each prompt. Copilot reads .github/copilot-instructions.md, and most other agents have an equivalent instructions file:
## Test rules for AI agents
- Expected values come from openapi.yaml or features/*.feature, never from a live response.
- Every test asserts the status AND a business field or schema.
- Never weaken, skip or delete a failing test to make CI green. Report the failure.
- No real customer data in fixtures, prompts or recorded responses.
The review gate
Agent output goes through the same gate as human output: a branch, a pull request, CI, and a human approval before merge. Branch protection enforces the last part so nobody has to remember it. When I review generated tests I look for a short list of problems:
- Snapshot assertions that copy the current response and call it a specification.
- Status-only tests that inflate the count without adding coverage.
- Invented behaviour: fields or error codes that look plausible but aren't documented.
- Self-grading changes: a pull request that changes product code and the tests that check it, where the test was edited to agree.
- Silent weakening: retries, sleeps, broader assertions or skips added to get to green.
My quickest check is to break the system on purpose. Change an expected value, point the test at the wrong ID, or stub a wrong response, and confirm the test fails. A test that can't fail is decoration, however many of them there are. There's a fuller checklist in reviewing AI-suggested test coverage before you commit it.
Agents running and triaging tests
Agents can also run the suite, read the failures and propose fixes. Diagnosis is a good use: "this fails because the status field was renamed in yesterday's commit" is a useful answer in seconds. The verdict, whether the test or the product is wrong, stays with a person who checks it against the spec. Any change to an expected value needs a written reason in the pull request.
Tooling is moving in this direction. MCP (Model Context Protocol) servers let agents call tools such as a browser, a test runner or an issue tracker in a structured way. That makes agent-driven exploratory testing possible: an agent probes an API or UI and reports what it found. I treat those findings like a new tester's notes. They're leads to confirm, not results to file, and anything worth keeping becomes a reviewed, deterministic test.
Testing LLM features: why one green run proves nothing
The second half of the picture is testing products that contain a model. Send the same input twice and you can get two different answers, both acceptable, or one acceptable and one not. Exact-match assertions break immediately, and a single passing run tells you very little.
The shift is from pass/fail to pass rate. Run each case several times, check each output against rules you can actually verify, and compare the rate to a threshold you've agreed on. The model call is injected, so the test doesn't depend on any particular vendor's SDK:
import json
def is_valid_refund_reply(text):
try:
data = json.loads(text)
except json.JSONDecodeError:
return False
return (
data.get("intent") in {"refund", "escalate"}
and isinstance(data.get("reply"), str)
and "@" not in data["reply"] # never echoes an email address
)
def pass_rate(generate, prompt, check, runs=10):
passed = sum(1 for _ in range(runs) if check(generate(prompt)))
return passed / runs
def test_refund_reply_is_well_formed(generate):
rate = pass_rate(generate, "Customer: my order arrived broken, I want my money back.",
is_valid_refund_reply)
assert rate >= 0.9, f"pass rate {rate:.0%} below 90%"
generate is a fixture that takes a prompt and returns a string, so you can point it at a real model in a nightly job and at a stub in unit tests. The threshold is a team decision, not a universal number; start where the feature is today and raise it.
A few more practices round this out:
- A golden dataset. A versioned set of inputs with expected properties, covering the common cases and the ones that went wrong before. Rerun it whenever the prompt, the model or the retrieval data changes, and compare against the last run. That's regression testing for prompts and models.
- Tool-call contract tests. When an agent calls your APIs, assert which tool it chose and that the arguments match the schema. Also test how your API handles the malformed arguments a model will eventually send.
- LLM-as-judge, checked. For qualities you can't express as a rule, such as tone or helpfulness, a second model can grade the output. But a judge is itself a model. Have people label a sample, compare the judge's grades to theirs, and recheck whenever you change the judge prompt or model.
- Guardrail tests. Prompt-injection attempts, requests for data the feature must not reveal, and off-topic requests, each with an expected refusal or safe behaviour.
- Tracing. Log the prompt, model version, tool calls and output for each test run, so a failure can be explained rather than just rerun.
Keep these model-calling tests separate from your deterministic suite and report them separately. A deterministic test that fails sometimes is flaky and needs fixing. A model-calling test that passes nine times in ten is reporting a measurement.
Data and privacy
AI-generated test data is handy for variety, but it has its own failure modes: values that look realistic and break business rules, duplicates and narrow distributions. Always validate generated data against your schema before you use it. The bigger risk is the other direction: pasting production records into a chat or prompt. Mask or synthesise first, and keep real customer data out of fixtures, recordings and eval sets. More on that in generating test data with AI without leaking real data.
Where to start
- Add an agent instructions file to your test repository with the rules above.
- Use Copilot or another agent for one mechanical task, such as step definitions or negative cases, and review it with the break-it-on-purpose check.
- Require human approval on every merge, agent-authored or not.
- If your product has an LLM feature, write one pass-rate test and one small golden dataset for it.
AI hasn't removed the need for testers. It has moved the work toward specification, review and measurement, which is where good testers were already strongest. If you want to practise this on a real API suite, my courses use GitHub Copilot throughout, with Python and Behave or Node and Cucumber, in VS Code.