QA AND TEST AUTOMATION · PART 12 · LEADING QUALITY (SENIOR AND STAFF) · STRATEGY · 107 OF 112

Risk-Based Testing: Prioritize What Matters

Risk-based testing spends test effort where failure would hurt most. A risk register for ShopRung, scored likelihood times impact, compared with what its suites really cover: the account area had 6 API tests yet none on sign-up, so a broken name rule slipped through. Then the two highest-value missing tests, written and proven against their planted bugs, and risk-based selection for a pricing change.

  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

  • Likelihood x impact
  • real coverage
  • 6 account tests, 0 on sign-up
  • fix gaps by risk
  • select by risk

Notes

Score the risks

Score each area on two scales. Likelihood: is the code complex, does it change often, has it broken before, is it new technology like the AI chat? Impact: does a failure lose money, leak data, break a law, affect many users, or leave no workaround? Multiply them. Do it with developers and the product owner, because each sees different risks. The numbers are judgement, written down so they can be argued with.

How to score
  • likelihood 1-3: complex code, frequent change, past bugs, new tech (the AI chat)
  • impact 1-3: money, data, legal, many users, no workaround
  • risk = likelihood x impact
  • score with dev and product, not alone

The register

Here is a register for ShopRung. Prices and coupons score highest: many rules, frequent changes, and every mistake costs money. Orders and access are less likely to break but a leak is serious. The AI chat is new and changes often. Accounts rarely change, but a broken sign-up stops every new customer. These are the team's estimates, not measurements, and that is fine: their job is to set priorities.

Risk register (judgement)
area             L  I  risk
prices, coupons  3  3   9
orders, access   2  3   6
AI chat          3  2   6
cart and stock   2  2   4
accounts         1  3   3
search           2  2   4
speed            2  2   4

Compare with coverage

Now compare with what the suites really do, using the bug matrix from the last episode. Prices: five API tests, three of four planted bugs caught. Orders and cart: everything caught. Search: no API tests, but the UI and load tests caught both bugs. The AI chat: five of six. And accounts: six API tests, the most of any area, and zero of one bug caught.

From the bug matrix
area       API UI  bugs caught
prices      5   2   3 of 4
orders      5   1   2 of 2
cart,stock  5   1   2 of 2
accounts    6   1   0 of 1
search      0   2   2 of 2*
AI chat    evals, red team,
            agent: 5 of 6
*slow-search via k6

The mismatch

Why? All six account tests are about logging in and tokens. Sign up, requirements one to five, has no test at all, so a fifty one character name is accepted unnoticed. The number of tests in an area says nothing about which risks they cover. Map tests to requirements, not to areas, and the hole is obvious: risk score three, coverage zero.

What the account tests check
login returns a token
bad login: same message (2)
email not case-sensitive
cart needs a token
tampered token refused

sign-up (ACC-1 to ACC-5):
  not one test
name-length bug: not caught

Fix the top gaps

Fix the gaps in risk order. Rounding is in the highest risk area: SAVE ten on fifty four ninety seven, a subtotal with half a cent in the discount. On the normal shop the discount is five fifty; with the rounding bug, five forty nine, so the new test fails as it should. Then the cheap one: sign up with a fifty one character name. Normally refused with a clear message; with the bug, accepted with two oh one.

New tests, run for real
PRICE-6: SAVE10 on $54.97
  (2 x $24.99 + $4.99)
  normal: discount $5.50
  discount-rounding: $5.49 → fail
ACC-2: sign up, 51-char name
  normal: 400 "Name must be 1
  to 50 characters"
  name-length: 201 → fail

Select by risk

Risk also decides what runs first. For a pull request that changes pricing, run the pricing tests first: five tests in half a second, the fastest useful signal. Then the full suite. On ShopRung the difference is small, but on a product with hours of tests, selecting and ordering by risk is how teams get fast feedback without skipping what matters.

Run the risky tests first
pytest -k "save10 or flat5
  or coupons or shipping"
  5 passed, 18 deselected
  in 0.50 s
then the full API suite:
  23 passed in 1.74 s
at scale: minutes vs hours,
  so order and select by risk

Depth by risk

Risk decides depth, too. The highest risk areas get every technique: boundaries, pairwise combinations, exploratory sessions and code review, at several layers. Medium risk gets API coverage, the main journeys and security tests. Low risk gets the happy path and its most important boundary. And the register is reviewed every release and after every incident, because risks move.

Effort follows risk
  • risk 9: boundaries, pairwise, exploratory, reviews, every layer
  • risk 6: API and key journeys, security tests
  • risk 3-4: happy path plus one boundary
  • review the register each release, and after incidents

Common mistakes

Mistakes. Counting tests per area as if that measured coverage. Scoring risks alone, without developers and product. Writing the register once and never updating it. Testing everything to the same depth. Treating low risk as untested, when it still deserves a happy path. And no traceable link from each risk to its requirements and to the tests that cover them.

Avoid these
  • counting tests per area
  • scoring risk alone
  • a register written once and never updated
  • equal depth everywhere
  • "low risk" meaning "untested"
  • no link from risk to requirement to test

Say it like this

In the interview: by risk, likelihood times impact, scored with developers and product. Then I map tests to requirements rather than counting them by area: on our shop, the account area had six tests and none on sign up, so a name bug slipped through. I fix gaps in risk order, prove each new test fails on its bug, run risky tests first, and review the register every release.

In the interview
  • "By risk: likelihood times
  • impact, scored with dev and product. Then I map tests to requirements, not areas: on our shop, the account area had six
  • tests and none on sign-up, so a name bug slipped. I fix gaps in risk order, run risky tests
  • first, and review the register
  • every release."

Interview questions

Q1What is risk-based testing?

Putting test effort, order and depth where failure is most likely or would hurt most.

Q2How do you score a risk?

Likelihood (complexity, change, past bugs, new technology) times impact (money, data, legal, users, workarounds), usually 1 to 3 each, scored with developers and product.

Q3Why is "tests per area" a poor measure of coverage?

ShopRung's account area had 6 API tests, all on login and tokens, and none on sign-up, so the name-length bug was not caught.

Q4How do you find mismatches between risk and coverage?

Map tests to requirements and run planted bugs; high-risk requirements with no failing test are the gaps.

Q5Which missing test was most valuable on ShopRung?

Rounding (PRICE-6) in the highest-risk area: SAVE10 on $54.97 should give $5.50; the bug gives $5.49.

Q6What is risk-based test selection?

Running the tests for the risky, changed area first (5 pricing tests in 0.5 s) before the full suite.

Q7Does low risk mean no tests?

No: a happy path and the most important boundary; risk sets depth, not existence.

Q8When should a risk register be updated?

Every release, after every incident, and whenever the product or architecture changes.