niloy.zaman
← All writing

AGENTIC TESTING / CASE STUDY

Building an agentic testing framework

AI agents that navigate workflows, generate test data, run tests, and route defects with evidence, and the guardrails that make their verdicts trustworthy enough to act on.

5 stagesNAVIGATE → ROUTE
PlaywrightPYTHON EXECUTION LAYER
Azure DevOpsCI PIPELINES

The problem

Regression testing for financial software is slow when every run depends on people. Someone has to set up test data, walk through each workflow, re-run flaky checks, collect screenshots and logs, and write up the defect. As release cadence went up, that manual overhead became the bottleneck, not the testing itself.

Traditional automation only solved part of it. Scripted click paths break whenever the UI changes, fixtures go stale, and when a suite goes red, a person still has to work out whether it's a real defect, a flaky test, or an environment problem. The expensive part of a regression cycle wasn't running the tests. It was everything around them.

What I built

I designed an AI-assisted framework where agents handle the repetitive parts of a test cycle end to end:

Agentic testing pipelineCopilot Studio agents coordinate five stages: navigate, generate data, execute, collect evidence, route defect. Each stage produces structured output. An engineer reviews before a ticket is filed.COPILOT STUDIO AGENTS · coordinate runs · answer “what failed, and why?”STAGE 1Navigateactions takenstep logSTAGE 2Generate dataedge-case inputssynthetic dataSTAGE 3Executepass / failPlaywright · ADOSTAGE 4Collect evidencescreenshots · logsnetwork tracesSTAGE 5Route defectowner + classrepro stepsSTRUCTURED OUTPUT AT EVERY STAGEEngineer reviews → ticket filed
Each stage hands structured output to the next, so every defect arrives with its evidence attached, and a person makes the final call.
  • Navigate: agents explore application workflows from a description of the goal ("open a report, apply a filter, export it") instead of following brittle, hand-coded click paths.
  • Generate test data: realistic inputs are created for each scenario, including edge cases, rather than copied from stale fixtures.
  • Execute: runs plug into the existing Python and Playwright suites and Azure DevOps pipelines, so agent-driven tests sit alongside the deterministic ones instead of replacing them.
  • Collect evidence: screenshots, logs, network traces, and steps to reproduce are gathered automatically at the point of failure.
  • Route defects: failures are classified and sent to the right owner with the evidence attached.

On top of this, I built custom Copilot Studio agents that coordinate test runs and support triage, so engineers can ask in plain language what failed, why, and what changed since the last green run.

The key design choice: every stage produces structured output, not free text. A navigation step records the actions it took, a data step records what it generated, and a verdict records the evidence behind it. That structure is what makes the next section possible.

Testing the tester

An agent that tests software also needs testing. A framework that quietly passes broken builds is worse than no framework at all, because it gives the team false confidence. I treated the agents as a system under test in their own right, with four layers of guardrails.

Four guardrails for AI test agentsFour layers of guardrails, each catching a different failure: seeded defects catch missed bugs and false alarms; human comparison catches wrong triage; the evidence rule catches hallucinated failures; human decisions catch unsafe actions.CATCHES1Prove it catches what it shouldseeded defects must be flagged; known-good builds stay cleanmissed bugs · false alarms2Compare verdicts with humanslabelled failures become the agents' own regression suitewrong triage3No evidence, no verdictevery pass or fail links to a screenshot, log line, or assertionhallucinated failures4A human decidesagents propose; engineers file tickets and make release callsunsafe or wrong actions
Four guardrails, each catching a different way an AI test agent can be wrong, before anyone relies on its verdicts.

1. Prove it catches what it should

The first question for any test tool is "does it fail when the software is broken?" I validated this with known-bad builds: environments with defects deliberately seeded into them (a wrong calculation, a missing field, a broken export). The agents must flag every one. A seeded defect that slips through is a bug in the framework, not in the product, and it gets fixed before the framework is trusted on real releases.

The reverse matters too. Running against a known-good build should produce no defects. Every false alarm costs an engineer's time and erodes trust in the tool, so false positives are tracked as seriously as misses.

2. Compare agent verdicts with human verdicts

Before the agents' triage was relied on, their verdicts were checked against an engineer's on the same set of failures: real defect, flaky test, environment issue, or expected change. Where they disagreed, I looked at why. Usually the cause was missing context in the prompt or an evidence gap, not a model limitation. That labelled set then became a regression suite for the agents themselves, re-run whenever a prompt, model, or tool changed. It's the same golden-set approach I describe in my LLM testing checklist.

3. No evidence, no verdict

Every pass or fail must point to the evidence behind it: the screenshot, the log line, the assertion that failed. An agent that says "this looks broken" without evidence isn't allowed to raise a defect. This one rule removes most hallucinated failures, and it means anyone can audit a verdict in seconds instead of re-running the test.

4. Keep a human on the decisions that matter

Agents propose and engineers decide. The agents do the busywork: running, collecting, classifying, and drafting the defect. A person reviews before a ticket is filed or a release call is made. Agents also run with tight boundaries: test environments only, synthetic data only, and a limited set of allowed actions, with every step logged so a run can be replayed.

Handling non-determinism

LLM-driven agents don't take the exact same path twice, so flakiness has to be designed for rather than wished away:

  • Constrain the variance: low-temperature settings, versioned prompts, and fixed tool definitions, so a change in behaviour can be traced to a change in inputs.
  • Re-run before reporting: a failure is retried in a clean state. One that only fails some of the time is classified as flaky and quarantined with its evidence, not filed as a product defect.
  • Assert on outcomes, not paths: checks target the end state (the report exported with the right values), not the exact clicks the agent took to get there.
  • Keep the critical paths deterministic: the highest-risk flows still have scripted Playwright tests. Agents widen coverage around them rather than replacing them.
Failure triage flowA failing test is retried in a clean state. If it does not fail every time, it is classified as flaky and quarantined with evidence. If it fails consistently, it is classified as a real defect, environment issue, or expected change, and an engineer reviews before a ticket is filed.Test failsRetry in aclean stateFails everytime?noFlaky → quarantinekept with its evidenceyesClassify, evidence attacheddefect · env · expected changeEngineer reviews → ticket
A failure is retried before it's reported. Only consistent failures are classified, and a person confirms before a ticket is filed.

What changed

  • Defects arrive ready to work on: evidence and steps to reproduce are attached, so there's no back-and-forth to reproduce the issue.
  • Triage is a review, not an investigation: engineers confirm or correct a classification instead of starting from a red pipeline.
  • Engineers spend time where risk is: exploratory testing and high-risk scenarios get the attention that repetitive regression used to take.
  • Release decisions rest on evidence: go/no-go discussions start from a classified list of failures, not a raw test report.

What I learned

Automation removes the busywork. Judgment about risk still belongs to the team.
  • Trust is the real deliverable. An agent's output is only useful if people act on it, and they only act on it if they can verify it quickly. Evidence-first design mattered more than clever prompting.
  • Test the framework before the product. Seeded defects and a labelled verdict set should exist before the agents touch a real release, not after the first missed bug.
  • Agents complement scripts, not replace them. Deterministic tests are still the best tool for critical, stable paths. Agents earn their keep in the long tail of workflows that are too costly to script and maintain.
← All writing Talk to me about this