The problem
When a build fails 100 of 800 automated tests, our SDETs spend about two days working out why. For each failure they have to decide: is the script wrong, did the run go wrong, or did the app break?
Those are three different problems with three different owners.
| Verdict | What it means | Who fixes it |
|---|---|---|
| Script issue | The test is out of date or badly written: a locator, a wait, stale expected text | SDET |
| Run issue | The environment, device, network or test data failed | SDET or infrastructure |
| Product bug | The app behaves differently from the requirement | Developer |
The two days are not all analysis. Part of it is waiting in a queue and switching between tests. But reviewing failures one at a time is the part we can change.
Why “let AI read the test” falls short
The obvious idea is to give an AI the original test cases and ask why each one failed. It does not work well, because the test source cannot separate a script issue from a bug. Both fail on the same assertion.
What separates them is evidence from the failed run:
- What the screen actually showed (screenshot and UI hierarchy)
- What the app logged, including crashes
- Whether the test passed on a rerun
- What changed in the app and in the test repo since the last green build
Without these, a model is guessing from the test code. With them, many failures can be decided by simple rules before any AI is involved.
The reframe: triage clusters, not tests
100 failed tests are rarely 100 problems. In practice they collapse into somewhere around 5 to 15 root causes, because many tests share the same login helper, the same screen, or the same flaky environment.
One renamed button in a shared login step can fail 14 tests at once. That is one fix, not 14 investigations.
So the unit of work changes. Group failures by error type, normalized message and failed step first. Judge each group once. People then review groups, not individual tests.
Before and after
The same failed build gets a different unit of work: people review a few clusters with evidence attached instead of every test.
About 2 days of SDET time per failed build
AfterTarget: about 2 hours, not yet measured
The two-hour figure is a target, not a measured result.
The pipeline
Each stage removes work before the next one runs, so the AI only sees what rules could not settle.
| Stage | What it does | AI needed? |
|---|---|---|
| 1. Cluster | Group by error type, normalized message and failed step | No |
| 2. Rerun | Rerun each failure once. A pass points to a run issue | No |
| 3. Rules | Known infrastructure signatures (session not created, device timeout, HTTP 503) become run issues | No |
| 4. Evidence bundle | Per cluster: test step, stack trace, screenshot, UI hierarchy, app logs, pass history, app and test diffs since the last green build | No |
| 5. Verdict | A model returns script, run or bug, a confidence score and the evidence it relied on | Yes |
| 6. Route | Run issue: retry or infrastructure ticket. Script issue: draft a fix PR. Bug: draft a ticket with repro. Low confidence: SDET queue | Partly |
The strongest single signal is the diff since the last green build. If the app change touched the failing screen and the test did not change, a script issue is likely. If neither changed and a rerun passes, it is a run issue. If locators resolve but the behavior is wrong, it is likely a bug.
Decision table and guardrails
The worst mistake is calling a real bug a script issue. A wrong “bug” label costs a developer ten minutes. A wrong “script issue” label can ship a defect. When the app contradicts the requirement, it is a bug even if editing the assertion would turn the test green.
| What you see | Likely verdict |
|---|---|
| Session not created, device queue timeout, HTTP 503 | Run issue |
| Passes on rerun | Run issue (flaky) |
| Account locked, test data used up | Run issue (test data) |
| Locator missing, UI hierarchy shows a new id, app diff renamed it | Script issue |
| Timeout on an element that now loads later | Script issue (wait) |
| Unexpected system dialog blocks a tap | Script issue |
| Locators work, but a value or behavior is wrong | Bug |
| App crash in the app logs | Bug |
Four rules keep the process honest:
- Every verdict cites evidence: a log line, a diff hunk or a hierarchy element. No evidence, no verdict.
- A script-issue verdict closes only after the fix passes on a rerun.
- Confidence below 0.8 goes to a person.
- Spot-check one or two tests in every large cluster, since one cluster can hide a second cause.
Getting the data from TestMu and Kiro
You do not need to export 100 tests by hand. TestMu’s REST API exposes build and session status, errors, command, console and network logs, screenshots and video per session, and its Automation MCP server pulls test details and logs into an AI chat. A short script, or an MCP-connected assistant, replaces a day of manual exporting.
Kiro reads project skills from .kiro/skills/, and the whole .kiro/ folder commits with your code, so every SDET gets the same setup. Kiro can also read the app and test repo diffs from git, which TestMu does not hold.
Three things to check before you build:
- Most TestMu documentation describes web automation. If your tests are mobile, confirm the app automation API exposes the same logs and screenshots.
- TestMu’s built-in root cause analysis is priced in credits per analysis. Cluster first, then analyze one representative per cluster instead of every failure.
- Test API rate limits on a single build before running a large export.
Rollout and metrics
Build the answer key before the AI. Without labeled past failures you cannot tell whether the classifier beats a coin flip.
| Phase | Work | Rough time |
|---|---|---|
| 0. Answer key | SDETs label every failure from the last 5 to 10 failed builds as script, run or bug | 1 week |
| 1. Rules only | Cluster, rerun, apply infrastructure rules and pass history. No AI | 2 to 3 weeks |
| 2. Model verdicts | Run the classifier on what is left and score it against the answer key | 3 to 5 weeks |
| 3. Act on verdicts | Auto-retry run issues, draft fix PRs for script issues, draft tickets for bugs | 6 weeks on |
The timings are planning estimates, not measured results. Track four numbers from day one:
- Time from build failure to triaged verdict
- Accuracy per verdict class
- Share of failures resolved without a person
- Real bugs labeled as script issues (the target is zero)
Store every final human verdict as a label. That is how the answer key grows and how you catch the classifier drifting.
Get the skill
The approach is packaged as a skill file, test-failure-triage, that an AI assistant can follow when you hand it a failed build. It contains the clustering steps, the evidence checklist, the decision table above, the output format for each cluster, and the guardrails.
A synthetic sample is included for practice: 100 failures across 11 root causes, with a separate answer key. It includes a renamed login button that fails 14 tests, an account-locked failure that looks like a bug but is test data, and a few real bugs that a careless classifier would call script issues. The sample is made-up data, not a real TestMu export.