QA AND TEST AUTOMATION · PART 11 · AI TOOLS FOR TESTERS · BASICS · 97 OF 112

Prompting for Testers: Test Cases and Data From AI

What a prompt changes when you ask AI for test cases, measured on a local model (llama3.2:3b) with ShopRung's coupon and shipping rules, three runs per prompt: a vague prompt invented features, a structured one covered every rule but made confident mistakes, and a worked example brought exact boundary values with wrong expected results. How to prompt, and how to review what comes back.

  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

  • Vague: invented features
  • structured: real rules, wrong values
  • few-shot: exact, still wrong
  • you own expected values

Notes

Prompt 1

First, the prompt most people type: write test cases for the coupons and shipping of an online shop. One run answered with Python code for coupon and shipping classes that do not exist. The other two gave generic cases with no amounts and nothing traceable to a requirement. The model had nothing to go on but other shops, so that is what it tested.

"Write test cases for the
coupons and shipping of an
online shop."

run 1: Python code for Coupon
  and Shipping classes that do
  not exist
runs 2, 3: generic cases
no amounts, no rule ids

Invented

And it invented. Coupon already used, cancelled coupons, express and international shipping, shipping cost by weight and size: ShopRung has none of these. Worse, one case expected multiple coupons with the maximum discount applied, which contradicts the rule of one coupon per order. A tester who pasted this into a test plan would test features that do not exist and assert the opposite of a rule that does.

From the vague prompt
  • coupon already used
  • cancelled coupon
  • express and international shipping
  • shipping by weight and size
  • "multiple coupons: maximum discount is applied" (ShopRung: one coupon per order, PRICE-2)

Prompt 2

The second prompt did what prompting guides recommend. A role. The actual requirements, pasted in full. The techniques to use: boundary values and equivalence partitions, at, just below and just above each limit. An instruction to use only the requirements and put anything unclear under questions. And an exact output format, a CSV with the rule id in every row.

The structured prompt
  • role: a senior software tester
  • the requirements: PRICE-2 to PRICE-10, pasted in full
  • technique: boundary values, equivalence partitions
  • "use ONLY what the requirements say; list the rest under QUESTIONS"
  • output: CSV id,rule,title, steps,expected

Better, still wrong

The structure worked for the shape: every run used the real rule ids and coupon codes, ten to sixteen cases each. But each run also contained confident mistakes. Free shipping at fifty dollars, when it starts at seventy five. WELCOME fifteen giving fifteen percent off, when it expired. FLAT five as ninety five percent of the price. And none of the runs tested one cent below a limit with an actual amount, though the prompt asked for exactly that.

Structured prompt, 3 runs
every run: rule ids, real
  codes, 10 to 16 cases
run 1: "subtotal $50.00 →
  shipping should be free"
  (free starts at $75.00)
run 2: "WELCOME15 → apply 15%"
  (it expired)
run 3: FLAT5 = "95% of the
  price" (it is $5.00 off)
no case one cent below a limit

Prompt 3

The third prompt added a worked example: two rows showing the style we wanted, a case exactly at twenty dollars and one at nineteen ninety nine, with exact expected values. This is called few shot prompting. Examples are the strongest signal you can give a model about format and level of detail.

Two example rows (few-shot)
TC-01,PRICE-4,$20.00,Apply FLAT5,
  Discount $5.00; total $15.00
  + $4.99 shipping = $19.99
TC-02,PRICE-4,$19.99,Apply FLAT5,
  Refused: needs $20.00 or more
"exact values only, never
  'correct'"

Exact, and wrong

Now the cases had exact amounts, including fifty dollars and forty nine ninety nine. But the expected results were wrong: SAVE ten at fifty dollars became five percent, two fifty, and at forty nine ninety nine both runs gave a discount instead of a refusal. Free shipping appeared at seventy four ninety nine. One run copied our two example rows word for word, and one refused the request entirely. Precise looking output is not correct output.

Few-shot prompt, 3 runs
$50.00 and $49.99 cases: yes
SAVE10 at $50.00: "5.00% =
  $2.50" (it is $5.00)
SAVE10 at $49.99: discounted
  in both runs (it is refused)
"$74.99 → free shipping"
run 1 copied the 2 examples
run 3: "I can't assist with
  that request."

Use it well

So use AI for what it is good at: brainstorming scenarios you might miss, drafting data, and formatting. Keep the parts that need correctness: you pick the boundaries from the rules, and you own every expected value. Compute money with code, like the pricing tests from Part three, never with a language model. Then review each row against its rule id and delete what you cannot trace. Larger models make fewer mistakes, but the review stays.

A workflow that holds up
  • AI: ideas and scenarios you missed, data shapes, format
  • you: the boundaries from the rules, and every expected value
  • compute money with code, not with a language model
  • check each row against its rule id; delete the rest

Prompt checklist

A tester's prompt checklist. Paste the real requirements, not a summary. Name the technique. Give the exact output format and one or two example rows. Tell it to use only what is stated and list everything else as a question. Never paste real customer data or secrets into a cloud model; use test data. And plan the review before you send the prompt.

Checklist
  • the real requirements text
  • the technique to apply
  • the exact output format
  • one or two example rows
  • "only what is stated, list the rest as questions"
  • test data rules: test accounts, no real customer data
  • then: review, run, keep

Common mistakes

Mistakes. Prompting without the requirements, so the model tests some other shop. Trusting exact looking values. Letting the model do the arithmetic. Pasting the output straight into a test plan. Judging a model from one run, when three runs of the same prompt gave different mistakes each time. And putting real customer data into prompts.

Avoid these
  • no requirements in the prompt
  • trusting exact-looking values
  • letting the model do the math
  • pasting the output into the plan unreviewed
  • one run, judged as the model's ability
  • real customer data in prompts

Say it like this

In the interview: yes, for drafts. I paste the real requirements, name the technique, and give the output format with an example. That improves the shape, not the correctness: in our runs the model invented features and wrote wrong totals and boundaries with complete confidence. So I choose the boundaries from the rules, compute expected values myself, and trace every case to a rule id before it goes into the plan.

In the interview
  • "For drafts. I paste the real
  • requirements, name the technique, give the format and an example.
  • The output gets better shaped, not reliably correct: in our runs it invented features and wrong totals. So I choose the boundaries, compute expected
  • values myself and trace every case to a rule id."

Interview questions

Q1What should a prompt for test cases contain?

The real requirements text, the test design technique, the exact output format, one or two example rows, and an instruction to use only what is stated and list the rest as questions.

Q2What happened with a vague prompt on ShopRung's rules?

llama3.2:3b wrote code for classes that do not exist or generic cases, invented features (express shipping, used coupons) and even contradicted the one-coupon rule.

Q3Did the structured prompt fix the quality?

It fixed relevance and traceability (rule ids, real codes), but every run had confident errors, such as free shipping at $50.00 and an expired coupon giving 15% off.

Q4What is few-shot prompting?

Including worked examples of the output you want. On ShopRung it brought exact boundary amounts, but the expected results were still wrong and one run copied the examples.

Q5Which parts of test design should stay with the tester?

Choosing boundaries from the rules and every expected value; money should be computed with code, not by a language model.

Q6Why run a prompt more than once?

Output varies: three runs of the same prompt made different mistakes, and one few-shot run refused the request entirely.

Q7What must never go into a prompt to a cloud model?

Real customer data, credentials and other secrets; use test data and test accounts.

Q8How do you review AI-written test cases?

Check each case against its rule id, recompute every expected value, delete what cannot be traced to a requirement, and add the boundaries it missed.