QA AND TEST AUTOMATION · PART 11 · AI TOOLS FOR TESTERS · PRACTICE · 102 OF 112

Self-Healing Tests and AI Failure Triage: The Risks

Self-healing tests and AI failure triage promise less maintenance, and both can hide bugs. Measured on ShopRung: a renamed id broke a CSS locator while a role locator kept working, updating a snapshot during a bug turned the bug into the baseline, and a local model sorted 12 real failure logs correctly only 8 times, with or without a careful prompt, calling a product bug an environment problem.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 11

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Role locators survive
  • snapshot update made the bug the baseline
  • triage 8/12, either prompt
  • rules first, people decide

Notes

What breaks

First, what self healing is meant to fix. We renamed the coupon field's id on ShopRung, a harmless refactor a developer might do. The test using a CSS id locator timed out. The test using a role and label locator, the textbox named Coupon code, kept working and applied the coupon. Most of the breakage self healing repairs never happens with role, label and test id locators. Fix the locators before buying a healer.

id "coupon" → "coupon-code"
locator('#coupon')
  TimeoutError: locator.fill:
  Timeout 3000ms exceeded
  waiting for locator('#coupon')
getByRole('textbox',
  { name: 'Coupon code' })
  → filled, FLAT5 applied
  → passed

Healing values

Healing values is more dangerous than healing locators. We recorded an ARIA snapshot of the cart totals for a seventy five dollar order. Notice the generated baseline turned the amounts into patterns for any number, so it never checked them. Then we switched on the free shipping bug: the test went red, correctly. Running update snapshots made it green again with a one line change, and the bug became the expected result.

toMatchAriaSnapshot, $75.00 cart
generated baseline:
  /Subtotal \$\d+\.\d+ ... Shipping
  Free Total \$\d+\.\d+/
free-shipping-boundary bug on:
  "Shipping $4.99" → test red
npx playwright test
  --update-snapshots → green
- Shipping Free
+ Shipping \$\d+\.\d+

Heal safely

So set rules for any healing tool, an AI agent or a snapshot update. Heal locators, never expected values or assertions. Every heal is a diff someone reviews; nothing is merged automatically. A snapshot update needs a reason in the pull request. Read generated baselines, because patterns can quietly stop checking amounts. And prefer locators that do not need healing.

Healing rules
  • heal locators, never expected values or assertions
  • every heal is a reviewed diff, never auto-merged
  • a snapshot update needs the reason in the pull request
  • check generated baselines: patterns can hide amounts
  • role and label locators first

Triage test

Now triage. We built twelve failure logs with known causes, taken from failures earlier in this course: four product bugs, three test bugs, three environment problems and two flaky tests. A local model, llama three point two at temperature zero, labelled each one in JSON. First with a naive prompt listing the four categories, then with a guided prompt that defined each category, required a quoted line of evidence and allowed unsure.

The triage set
  • 4 product bugs: coupon edge, order leak, stock, slow search
  • 3 test bugs: wrong expectation, locator typo, missing fixture
  • 3 environment: server down, Ollama down, no browser
  • 2 flaky: passed on retry, fails only in parallel
  • llama3.2:3b, temperature 0, JSON

Measured

Both prompts got eight of twelve right. The careful prompt was slower and never once used unsure. Both made the same important mistake: a test that expected the five dollar coupon on a fifteen dollar cart, when the rule says twenty, was called a product bug, even though the log quoted the rule. A team acting on that label would file a bug against correct code.

Agreement with the known cause
                 naive  guided
correct           8/12    8/12
answered UNSURE     -     0
time per log     2.1 s  3.0 s
both wrong: the test that
  expected FLAT5 at $15.00,
  log included the rule
  ($20.00) → "PRODUCT_BUG"

The costly errors

Look at which mistakes cost most. The slow search bug was labelled environment, with evidence that was just the start of a log line. Environment failures get retried or ignored, so a real performance bug would disappear. The locator typo became environment, and the parallel data clash became a product bug. With the naive prompt, a server that was not running became a product bug. Quoted evidence did not make the reasoning right.

Guided prompt, wrong labels
slow search (k6 thresholds)
  → ENVIRONMENT, evidence:
  "level=error msg="
shared data in parallel
  → PRODUCT_BUG
locator typo "Add to basket"
  (page shows "Add to cart")
  → ENVIRONMENT
naive: server down → PRODUCT_BUG

Use triage well

Use triage the way Part ten used judges. Put deterministic rules first: a test that passed on retry is flaky, a connection error in every test is the environment. Let AI suggest a label and a reason for the rest, shown to a person, never acted on automatically. A person confirms before a bug is filed or a test is muted. And measure the triage against labelled failures before trusting it.

A triage pipeline
  • rules first: passed on retry → flaky; ConnectError in every test → environment
  • AI: a suggested label and reason, shown, not acted on a person confirms before a bug is filed or a test muted
  • measure the triage on labelled failures, like a judge

Common mistakes

Mistakes. Healing expected values instead of locators. Merging heals automatically. Updating snapshots on a red build without a reason. Acting on AI triage labels without a person, especially when environment means nobody looks. Never measuring how often the triage is right. And using a healer to paper over fragile locators that role and label locators would have avoided.

Avoid these
  • healing expected values
  • auto-merged heals
  • --update-snapshots on a red build without a reason
  • acting on AI triage labels
  • "environment" means ignore it
  • never measuring the triage
  • fragile locators "fixed" by a healer

Say it like this

In the interview: useful for locators, dangerous for values. Role and label locators avoid most breakage in the first place. When we updated a snapshot while a bug was on, the bug became the baseline in a one line change. For triage, a local model was right on eight of twelve failure logs and called a performance bug an environment problem. So rules come first, AI suggests, and a person decides.

In the interview
  • "Useful for locators, dangerous
  • for values. Role locators avoid
  • most breakage. A snapshot update
  • during a bug made the bug the baseline in one line. For triage, a local model was right on 8 of 12 logs and called a slow-search
  • bug environment, so rules come
  • first, AI suggests, and a person
  • decides."

Interview questions

Q1What is a self-healing test?

A test whose tool repairs it when it breaks, usually by finding a new locator, and sometimes by updating expected values or snapshots.

Q2Why can self-healing hide bugs?

A red test may be right. Updating ShopRung's cart snapshot while the free-shipping bug was on made the bug the expected result in a one-line change.

Q3What reduces the need for healing?

Role, label and test id locators: after a coupon field id was renamed, the CSS id locator failed and the role locator kept working.

Q4What should a healing tool be allowed to change?

Locators, in a reviewed diff; never expected values or assertions, and never merged automatically.

Q5How accurate was AI failure triage on ShopRung's logs?

llama3.2:3b labelled 8 of 12 known failures correctly with a naive prompt and 8 of 12 with a guided one; it never answered UNSURE.

Q6Which triage mistake is most dangerous?

Labelling a product bug as environment or flaky, since those get retried or ignored; the slow-search bug was labelled environment.

Q7How should triage be built?

Deterministic rules first (passed on retry, every test failing to connect), AI as a suggestion with a reason, and a person deciding before a bug is filed or a test is muted.

Q8What did generated ARIA snapshots get wrong?

Playwright generalised the amounts into number patterns, so the baseline checked the word "Free" but not the totals.