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

How to Write a Test Strategy for a Product

A test strategy decides what to test, at which level, where it runs and how you know it works. Built for ShopRung from the suites in this course, then checked with evidence: all of ShopRung's 17 planted bugs, one at a time, against five suites. 14 were caught by at least one, the UI suite found a bug the API suite missed, and 3 were caught by nothing.

  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 / 12

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

Key takeaways

  • Risks first
  • cheapest level
  • where it runs
  • bug matrix: 14/17 caught
  • UI found what API missed
  • decide every gap

Notes

Start from risk

Start from what would hurt the business, not from tools. For ShopRung: money, wrong discounts, shipping or rounding. Access, one customer seeing another's order. Stock, selling what is not there. Account rules. Search, because customers who cannot find products do not buy. The AI support chat, which can be wrong, leak or be injected, and costs money per answer. And speed. Each risk needs at least one test that would catch it.

ShopRung's product risks
  • money: wrong discounts, wrong shipping, rounding
  • access: another customer's order
  • stock: overselling
  • accounts: sign-up and login rules
  • search: customers cannot find products
  • AI chat: wrong, leaked or injected answers; cost
  • speed: slow search and chat

Pick the level

For each risk, pick the cheapest level that can see it. Pricing rules at unit level. Business rules and access through the API: ShopRung has twenty three pytest tests. User journeys in the UI: seven Playwright tests, plus accessibility and visual checks. The AI chat with evals, agent tests and a red team suite. Speed with k6 and JMeter. And people, in exploratory sessions, for what nobody thought to automate.

ShopRung's layers
  • unit: pricing rules (lab 6)
  • API: 23 pytest tests (lab 11)
  • UI: 7 Playwright tests (lab 13), accessibility, visual
  • AI: evals 12 questions, agent 10 tests, red team 8 attacks
  • performance: k6 and JMeter
  • humans: exploratory sessions (lab 2), each release

Where it runs

Then decide where each runs. On every pull request, the fast deterministic suites: the API suite took two seconds, the UI suite four, and the three AI suites on the fake model under a second; about seven seconds in all. Nightly, what is slow or noisy: the k6 load test, evals and red team rates on a real model. Before each release, an exploratory session and accessibility checks.

ShopRung's schedule
every pull request:
  API 2.0 s, UI 4.0 s,
  AI suites on the fake model
  0.8 s: about 7 s in all
nightly: k6 load test, evals
  on a real model, red team
  rates
each release: exploratory
  session, accessibility

Test the strategy

Now test the strategy itself. ShopRung has seventeen planted bugs. We switched each one on, alone, reset the data, and ran five suites: API, UI, agent, red team and evals, recording whether any test failed. For slow search we used the k6 and JMeter results from their labs. This is the strongest evidence a strategy can have: known bugs, and whether anything noticed.

The bug matrix, run for real
  • ShopRung has 17 bugs you can switch on, one at a time
  • for each: reset, switch on, run API, UI, agent, red team and eval suites
  • a bug is caught if any test in a suite fails
  • k6 and JMeter results from their labs

Measured

The result. The API suite caught seven bugs, the UI suite three, including case sensitive search, which the API suite missed because it has no search tests at all. The evals and the red team suite caught three chat bugs each, the agent tests one, and the load tests caught slow search. Fourteen of seventeen bugs were caught by at least one suite. Three were caught by nothing.

Which suite caught what
API (23 tests)    7 bugs
UI (7 tests)      3 bugs
  incl. search-case: API missed
evals             3 chat bugs
red team          3 chat bugs
agent             1 chat bug
k6, JMeter        slow-search
caught by any:   14 of 17
caught by none:   3

The gaps

The three misses are worth reading. Discount rounding: SAVE ten on fifty four ninety seven gives five forty nine instead of five fifty, because no test uses a subtotal with half a cent. Name length: a fifty one character name is accepted, because no test signs up with a long name. And the slow chat adds three seconds per answer, still inside the ten second requirement, so only a latency budget would notice. Each gap is now a decision.

The 3 misses
discount-rounding: SAVE10 on
  $54.97 gives $5.49, not $5.50
  (PRICE-6)
name-length: a 51-character
  name is accepted (ACC-2)
chat-slow: +3 s per answer,
  still inside AI-7's 10 s;
  only a latency budget sees it

Decide

A strategy decides what to do about each gap, based on risk. Rounding loses money on real orders, so it gets an API test at fifty four ninety seven. The name rule is low impact, but the test costs a minute, so add it. The slow chat is within its requirement, so it gets a latency budget in the nightly run rather than a failing test. Write each decision down with its reason: that record is part of the strategy.

Gap decisions
  • discount-rounding: money on real orders → add an API test at $54.97
  • name-length: low impact → add a cheap boundary test
  • chat-slow: within the rule → a nightly latency budget
  • write the decision down, with its reason

The document

Keep the document to one page people will read. The product and its top risks. Which level covers what. Where and when each suite runs. Environments and test data. Entry and exit criteria for a release. The evidence: the bug matrix, escaped bugs and flakiness. Known gaps with their decisions. And owners, with a review every quarter, because the product and its risks change.

Strategy, one page
  • 1 product and its top risks
  • 2 test levels: what each covers
  • 3 where and when each runs
  • 4 environments and test data
  • 5 entry and exit criteria
  • 6 evidence: the bug matrix, escapes, flakiness
  • 7 known gaps and decisions
  • 8 owners; review every quarter

Common mistakes

Mistakes. A strategy that is a list of tools instead of risks. Testing everything through the UI, which is slow and fragile. Slow or noisy suites on every pull request, so people stop waiting for them. Never testing the strategy with known bugs. Using code coverage as the evidence. Leaving gaps undecided. And a thirty page document nobody reads.

Avoid these
  • a list of tools, not risks
  • everything at the UI level
  • slow suites on every PR
  • never testing the strategy
  • coverage % as the evidence
  • gaps nobody decided about
  • a 30-page document nobody reads

Say it like this

In the interview: I start from product risks. For each, the cheapest test level that can catch it, and where it runs: fast deterministic suites on every pull request, slow and noisy ones nightly, people before releases. Then I test the strategy with planted bugs. On our shop, fourteen of seventeen were caught; the three gaps became decisions, made by risk. One page, with owners, reviewed every quarter.

In the interview
  • "From product risks: for each, the cheapest level that can see
  • it, and where it runs: fast
  • suites on PRs, slow ones
  • nightly. Then I test the strategy with planted bugs. On our shop, 14 of 17 were caught;
  • the 3 gaps became decisions, by risk. One page, reviewed
  • quarterly."

Interview questions

Q1What is the difference between a test strategy and a test plan?

A strategy describes how a product is tested over time (risks, levels, where tests run, evidence); a plan describes what one release or feature will test.

Q2Where should a strategy start?

From product risks: what would hurt the business or users most, such as wrong prices, data leaks or a broken AI answer.

Q3How do you choose the test level for a risk?

The cheapest level that can see it: unit for rules, API for business logic and access, UI for journeys, evals for AI, load tests for speed, people for the unexpected.

Q4How can you test a test strategy?

Plant known bugs one at a time and see which suites fail. On ShopRung, 14 of 17 planted bugs were caught by at least one suite.

Q5Why did ShopRung's UI suite catch a bug the API suite missed?

Search case-sensitivity: the API suite has no search tests at all; the UI suite searches for MUG in capitals.

Q6What did no suite catch?

Discount rounding (no subtotal with half a cent), a 51-character name (no long-name test) and a slower chat that stayed within its 10-second requirement.

Q7What happens to a gap in coverage?

A recorded decision by risk: add a test, add a different check (such as a latency budget), or accept it with a reason.

Q8What goes in a one-page strategy?

Top risks, levels, schedule, environments and data, entry and exit criteria, evidence, known gaps with decisions, and owners.