AI-assisted testing

How AI can triage hundreds of test failures without hiding a defect

After a release, many tests can fail because of one shared cause. A language model can group similar outputs and prepare hypotheses, helping with the initial sorting known as triage. Similarity does not establish a cause, though. When verifying groups, retain evidence that does not fit the proposed explanation too.

Why the number of red tests is misleading

One defect can trigger a chain of failures. If sign-in is broken, order, profile, and administration scenarios may all fail. Conversely, two failures with the same Timeout message need not share a cause: one test may have waited for a slow API while another looked for an element that no longer exists on the page.

Opening similar reports repeatedly takes time. Labelling tests as unstable in bulk without checking can hide a real defect. A controlled rerun, by contrast, is useful when it tests a specific hypothesis. The proposed collect → redact → cluster → hypothesis → human verification workflow combines evidence collection, removal of sensitive data from a working copy, grouping, hypotheses, and human verification.

An illustrative example: 126 failures after one change

The following numbers form a fictional model of the process, rather than a measured incident. After a change to checkout, the final part of a purchase, an overnight run reports 126 failed tests. Sorting by the final message creates a Timeout group that mixes several problems. AI uses working copies to propose two broad groups and leaves thirteen cases undetermined. Human review divides the result into three confirmed groups.

The first group contains 83 scenarios that stopped during sign-in. They share the same authentication-service response and began failing at the same time, so a person checks service availability and one representative test. The second group contains 21 tests with missing data after a failed setup job. Repairing the environment removes both groups without changing the tests.

The third group contains nine checkout scenarios. AI places them with the general timeouts, but the network response is successful and the recording shows an incorrect order total. A reviewer separates them as a possible application defect. Reproduction with the relevant line items confirms an incorrect discount. Automatically accepting the explanation “environment problem” without checking the total could hide this defect.

The remaining thirteen failures do not have enough shared evidence. They stay in an “undetermined” category and receive individual review. The model ends with the allocation 126 = 83 + 21 + 9 + 13. The team resolves two bulk causes without losing the smaller group with business impact or the unclear cases.

1. Collect: gather comparable evidence

For each failed test, retain its stable ID, build and commit, time, environment version, browser or device, message, stack trace, and last steps. Depending on the tool, add network and application logs, a screenshot, or a recording of the run (trace). Playwright Trace Viewer lets you inspect actions, captured page state, console output, and network requests.

Keep the original evidence you need separately from the processed copy. Exact times and request identifiers help connect events from one operation. Set access controls and retention periods for these originals and their backups too. Do not collect unnecessary secrets just to make the archive complete. The OWASP Logging Cheat Sheet covers protection and disposal of logs and their copies.

Keep the result history as well. A single failure does not show whether the problem is a reproducible regression, random instability, or a one-off environment outage. We discuss practical measurement in How to measure flaky tests and identify instability patterns.

Give the evidence a consistent structure and mark missing fields. If one test provides a complete trace while another provides only “element not found”, the model may also group by differences in input quality.

2. Redact: remove sensitive information before AI sees it

Logs and traces may contain access tokens, cookies, personal information, form contents, request headers, or entire API responses. Removing or covering sensitive information, known as redaction, must happen before data is sent to a model. Reviewing its answer would be too late.

In the working copy, rules can replace an email address or identifier with a consistent placeholder such as <USER_17>. This preserves event connections without directly including the original value. The remaining context may still identify a person. Neither redaction nor a stable placeholder is automatically anonymisation, as the distinction in GDPR Recital 26 explains.

Verify masking in URLs, screenshots, and attachments too. A text rule does not cover image contents. If you cannot verify an artefact’s redaction, do not send it to the model. Where does your data go during AI-assisted testing? covers model choice, processing location, and retention.

3. Cluster: group failures using several signals

Create a normalised grouping input from the redacted copy. Build the error fingerprint from its type, code location, and last step. Standardise variable parts so a different timestamp does not create a new group. Keep the environment version and event connections through consistent operation identifiers, though. Do not overwrite original times and correlation data in the protected evidence. AI can add semantic similarity across text and symptoms, which still does not prove a shared cause.

The output should contain more than a group name. For each cluster, retain:

Forcing every failure into a group is dangerous. An “unknown” category is better than a convincing but unsupported merger of a real defect with an environment outage.

The output must be reviewable, not merely convincing

Each group needs a stable identifier and concise name, but also enough information to evaluate the decision later. A cluster record can include the dominant error fingerprint, affected tests and builds, first and last occurrence, shared artefacts, exceptions, and the proposed next diagnostic step. A link to the original trace is more valuable than a long summary without a source.

Keep three values separate: similarity, cause hypothesis, and priority. Two tests can be highly similar while their cause remains unknown. Conversely, one failed payment scenario can have higher priority than fifty failures in an internal report. A model may propose all three values, but they should not be collapsed into one ambiguous “confidence” score.

Retain the version of the normalisation rules, prompt, and model configuration as well. The goal is not to reproduce every word of an answer, but to explain why results changed between two runs. If a new version starts creating broader groups, the team has evidence for comparison rather than an impression that AI has simply become more confident.

4. Hypothesis: formulate an explanation, not a verdict

For one cluster, a model might propose: “The tests failed after a shared sign-in button locator changed.” It must attach supporting evidence, such as the same commit, a DOM snapshot without the original element, and a consistent failure location. It should also name alternatives: a partially loaded page could produce the same symptom.

Save the output as a proposal with links to specific evidence and notes on what is missing. A hypothesis alone does not authorise changes to tests or an incident’s status. The team owns the decision rules.

5. Human verification: a person confirms cause and impact

A tester or developer selects a representative failure from each cluster and reviews the original artefacts. They inspect the application change, reproduce the scenario or rerun it under controlled conditions, and compare the result with the hypothesis. For a large cluster, they also inspect several edge members so that two causes are not hidden under one name.

Only then does the team assign a state: application defect, test defect, data problem, environment problem, or not yet determined. The fix is made in the appropriate layer, and a subsequent run confirms that it removed the cause without weakening the assertions. If the suite is broadly damaged or untrusted, triage findings become input to repairing the existing test suite, not an automated substitute for that work.

Decision boundaries AI must not bypass

During the pilot, allow AI to read approved evidence and propose an output. Disabling a test, changing an expectation or timeout, quarantining a test, or writing to an incident or production system requires separate authority and the agreed approval. Enforce permissions in tools outside the model.

Logs and captured page text are untrusted inputs. They may contain instructions to change rules or send data elsewhere, known as prompt injection. Such text does not give an agent authority to act. OWASP recommends separating external content and restricting permissions. During the pilot, try an artefact containing a forged instruction and verify that tools reject the prohibited operation.

Distinguish report status from diagnosis. Playwright labels a test flaky when it passes on retry after failing. That does not establish the cause or show that it is harmless. Examine history under comparable conditions and possible differences in data or environment. Temporary quarantine needs an owner, reason, review date, retained failures, and alternative coverage for the important risk.

When artefact quality is poor, the system should request more evidence or leave the case undetermined. Without a stack trace, history, and environment information, saying “we do not know” is safer than inventing a specific cause from the test name.

How to verify that triage actually helps

Before regular use, prepare a small reference set of historical runs for which people know the confirmed causes. Hide those labels from AI, let it create groups, and then compare the result. Pay particular attention to incorrect mergers of distinct causes because they can hide a real problem. Producing too many small groups mostly reduces the time saving, but it is usually easier to notice.

Evaluate the same set using the previous manual process too. Compare incorrect mergers, the proportion of confirmed groups, corrections after review, the proportion of undetermined cases, and time to the first confirmed cause. Include the time spent preparing inputs and reviewing AI proposals. Keep the scope and evidence quality the same, otherwise a speed improvement may simply reflect easier input. Repeat the evaluation after a substantial change to the suite, reporter, or model.

A useful system gradually reduces repeated work without increasing incorrect mergers. If it creates quick summaries but a reviewer still has to inspect every artefact from the beginning, or regularly discovers hidden distinct causes, adjust the inputs, clustering rules, or AI scope rather than merely rephrasing the prompt.

The voluntary NIST AI RMF Generative AI Profile supports evaluating risks and verifying outputs in their use context. It does not prescribe this five-step process or specific triage metrics. Those are practical proposals in this article, rather than a NIST obligation or certification.

What you gain

Working groups supported by traceable evidence can reduce repeated reading of reports. Their value is confirmed only by comparison with manual triage that retains visibility of distinct and unclear failures. A fast summary without correctly separating causes is not enough.

Next step

Introduce a consistent artefact format and redaction rules for one failed run. Let AI propose only clusters and hypotheses, then manually verify both a representative and an edge case from each group. Add the workflow to regular run evaluation only after it repeatedly distinguishes causes without hiding defects.

Related topics

You might also be interested in

AI will speed up work. The person is responsible for the result.

AI speeds up the design, creation, repair and migration of web, Android, API and Electron tests; a specialist verifies every output before use.