QA AND TEST AUTOMATION · PART 0 · INTRODUCTION AND CAREERS · BASICS · 1 OF 112

What Is Software Testing? Why It Matters, With Examples

What software testing is and why teams pay for it, shown on one real shop rule: error, defect and failure, verification and validation, static and dynamic testing, test basis, condition and case, a test case written out and run, a bug caught with the ShopRung bug switch, and what testing can never prove.

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

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

Key takeaways

  • Expected vs actual
  • error, defect, failure
  • verify and validate
  • static and dynamic
  • rule → condition → case

Notes

One small rule

Meet ShopRung, the small practice shop this whole course tests. One of its rules, called price three, says the coupon SAVE10 takes ten percent off when the subtotal is fifty dollars or more. Now imagine a developer types greater than, instead of greater than or equal to. One character. Every customer with exactly fifty dollars in the cart is refused a discount they were promised. Nobody notices, unless somebody checks.

ShopRung, rule PRICE-3
"SAVE10 takes 10% off the subtotal
 when the subtotal is $50.00 or more"

the code a developer meant:
  if (subtotal >= 5000) apply()

the code a tired developer wrote:
  if (subtotal >  5000) apply()

a $50.00 cart: no discount

The idea

Here is the idea. Software testing is a set of activities that find defects and judge the quality of software, and of the documents behind it. At its heart is one comparison: what the software should do, the expected result, against what it really does, the actual result. A tester reports the gap and the risk it brings, so the team can decide what to fix and when to release.

Testing, in one line
  • a set of activities to find
  • defects and judge the quality
  • of software and its documents
  • it compares: what it should do (expected) what it really does (actual)
  • and reports the gap and the risk to the people who
  • decide

Error, defect, failure

Three words that interviews love. An error, or mistake, is something a person does, like typing the wrong comparison. The defect, also called a bug or a fault, is the wrong line that now sits in the code. A failure is what you see when that code runs and goes wrong, the fifty dollar cart with no discount. Testing usually finds failures. Developers then trace them back to the defect and fix it.

Three different words
  • error (mistake): a person types > instead of >=
  • defect (bug, fault): the wrong line now sits in the code
  • failure: running it goes wrong ($50.00 cart, no discount)
  • a defect in code nobody runs
  • never becomes a failure

Verify and validate

Testing asks two different questions. Verification asks, did we build it right? Does the coupon follow rule price three exactly? Validation asks, did we build the right thing? Do customers understand the coupon, and does it help the business at all? A product can pass verification perfectly and still fail validation, because the written rule itself was wrong. Good testers keep both questions in mind.

Two different questions
  • verification: did we build it right? does it match PRICE-3?
  • validation: did we build the right thing? do customers understand and want this coupon at all?
  • a product can pass one and fail the other

Static testing

Testing does not always mean running the software. Static testing examines things without running them: reviewing a requirement, reviewing code in a pull request, or letting a linter scan it. Dynamic testing runs the software and compares results. Static testing is cheap and early. For example, a tester reading the shipping rule asks, is free shipping based on the price before or after the discount? Rule price nine answers: after. One question, no code needed.

Static vs dynamic
  • static: examine, do not run review a requirement review code in a pull request linters and static analysis
  • dynamic: run the software and compare results
  • review question: is free
  • shipping before or after the discount? PRICE-9: after

Basis to test case

How does a rule become a test? Start from the test basis, the documents you test from. Here that is the requirements file. From it you pick test conditions, the things worth checking: SAVE10 at exactly fifty dollars, SAVE10 just below, at forty nine ninety nine, and the code typed in lower case, because rule price two says codes are not case sensitive. Each condition then becomes a test case with data, steps and an expected result.

From rule to tests
  • test basis: what you test from requirements.md, PRICE-3
  • test conditions: what to check SAVE10 at exactly $50.00 SAVE10 just below, $49.99 lowercase save10 (PRICE-2)
  • test case: one condition with data, steps, expected result

A test case

Here is that test case written out. The precondition: reset the data and log in as Alice. Add two green mugs at fifteen dollars and one t-shirt at twenty, which makes exactly fifty. Apply SAVE10. Expected: subtotal fifty dollars, discount five, and shipping four ninety nine, because forty five dollars is below the seventy five dollar free shipping line. Total, forty nine ninety nine. You work out every number before you run, never after.

TC-PRICE-3-02
checks: PRICE-3, PRICE-9, PRICE-10
pre: data reset, logged in as alice
1 add 2 x Green Build Mug   $15.00
2 add 1 x Ship It T-Shirt   $20.00
3 apply coupon SAVE10
expected:
  subtotal  $50.00
  discount  $5.00   (10%)
  shipping  $4.99   ($45.00 < $75)
  total     $49.99

Run it

Now run it. The tester follows the steps on the real shop, and every amount matches what we worked out: fifty, five, four ninety nine, forty nine ninety nine. The test passes. Notice what a pass really means. It is evidence that this one case works, on this build, today. It does not say the coupon is correct everywhere. That is why we never stop at a single test.

Run 1: bugs off
subtotal  $50.00   expected $50.00
discount  $5.00    expected $5.00
shipping  $4.99    expected $4.99
total     $49.99   expected $49.99

result: PASS

a pass is evidence, not proof:
it says this case works today

Catch a bug

ShopRung has a bug switch, a test-only setting that turns on known bugs, so you can prove your tests catch them. Switch on the one called coupon boundary and run the same test. Now the shop refuses the coupon, with a message saying it needs at least fifty dollars, on a cart of exactly fifty. Expected and actual differ, so the test fails. The tester writes a bug report, and the developer finds the wrong comparison and fixes it.

Run 2: coupon-boundary on
POST /api/test/bugs
{"enabled": ["coupon-boundary"]}

actual: "This coupon needs a
  subtotal of at least $50.00"
expected: $5.00 off

result: FAIL, report it

One rule, many tests

A good tester sees more than one test in that sentence. The forty nine ninety nine hoodie alone must be refused. Exactly fifty dollars must work. Lower case save ten must work. A second coupon must not stack, because only one coupon is allowed per order. And if the customer removes a mug after applying the coupon, the cart must explain why the discount is gone. One line of requirement, half a dozen tests.

Checks for SAVE10
  • $49.99 hoodie: refused
  • $50.00: accepted, $5.00 off
  • save10 typed lowercase: works
  • add FLAT5 too: only one coupon per order (PRICE-2)
  • remove a mug so subtotal falls under $50: cart says why and drops it (PRICE-8)
  • $54.98: $5.50 off (rounding, PRICE-6)

Why it matters

Why do teams pay for testing? Because the same bug costs very different amounts depending on when it is caught. In a requirement review, you change one sentence. In a unit test, a developer fixes it in minutes. Found by a tester, it means a report, a fix and a re-test. Found by customers, it means refunds, support tickets, an urgent release and lost trust. Testing early and often keeps the bill small.

Where the slip is caught
  • in review: edit one sentence
  • in a unit test: a developer fixes it in minutes
  • in a test run: a bug report, a fix, a re-test
  • in production: refunds, angry customers, an urgent release, lost trust
  • same bug, very different bill

What it cannot do

Be honest about the limits. Testing can show that bugs are present, never that they are absent. You cannot try every input either. ShopRung search accepts two to fifty characters, and the number of possible strings is astronomical, so testers choose wisely instead. Testing is also not debugging. Testing reveals the failure, debugging finds the cause. And testing does not add quality by itself. Fixing what it finds does.

Honest limits
  • cannot prove there are no bugs
  • cannot try every input: search text is 2-50 chars, far too many strings to try
  • is not debugging: testing finds the failure, debugging finds the cause
  • does not add quality by itself: fixing what it finds does

Rules of thumb

A few habits that make every test worth its time. Tie each test to a requirement id, so anyone can see what it proves. Write the expected result before you run, so the app cannot quietly change your mind. Check one condition per test. Start from clean, known data, which is why ShopRung has a reset call. Test the edges, not only the happy path. And keep evidence: a screenshot, the response, the row in the database.

Rules of thumb
  • tie each test to a rule id
  • write the expected result before you run
  • one condition per test case
  • start from clean, known data
  • test the edges, not just the happy path
  • keep the evidence: screenshot, response, SQL row

Common mistakes

Watch for these common mistakes. Testing only the happy path, where everything goes well. Deciding a result looks right without having written down what right means. Leaving testing to the very end, when fixes are most expensive. Trusting a requirement without asking whether it makes sense. Reporting coupon broken with no steps, data or evidence. And thinking testing means clicking around. It is thinking first, then checking.

Common mistakes
  • only the happy path
  • "it looks right" with no expected result written down
  • testing only at the very end
  • trusting the requirement without questioning it
  • reporting "coupon broken" with no steps or data
  • thinking testing = clicking

Say it like this

When an interviewer asks what is software testing, say something like this. Testing is how we find defects and measure quality before users do. I start from the requirement, work out the expected result, compare it with the actual result, and report the gap and its risk, so the team can make a good release decision. It can never prove there are no bugs, so I spend my effort where the risk is highest: edges, money and data.

In the interview
  • "Testing is how we find defects and measure quality before users do. I compare expected with actual, starting from the requirement, and I report the gap and its risk so the team can decide. It cannot prove there are no bugs, so I focus on risk: edges, money, data."

Interview questions

Q1What is software testing?

A set of activities that find defects and evaluate the quality of software and its work products, by comparing expected results with actual results. Its output is information about quality and risk that the team uses to decide what to fix and when to release.

Q2What is the difference between an error, a defect and a failure?

An error is a human mistake, such as typing > instead of >=. The defect (bug, fault) is the resulting flaw in the code or document. A failure is the wrong behaviour you observe when the defective code runs. Not every defect causes a failure, for example in code that never runs.

Q3What is the difference between verification and validation?

Verification checks that the product matches its specification: did we build it right? Validation checks that it meets the real needs of users: did we build the right thing? A feature can follow its requirement exactly and still fail validation if the requirement was wrong.

Q4What is static testing? Give an example.

Testing without running the software: reviewing requirements, designs or code, or running static analysis and linters. Asking in a review whether free shipping uses the price before or after the discount is static testing, and it can catch a defect before any code exists.

Q5Can testing prove that software has no bugs?

No. Testing can show that defects are present but never that they are absent, and exhaustive testing of every input is impossible for real software. Testers manage this by choosing tests by risk and using techniques such as boundary values.

Q6What is the difference between testing and debugging?

Testing finds failures and reports them. Debugging is the development activity of finding the defect that caused a failure, fixing it and checking the fix. Testers often help by giving precise steps, data and evidence that make debugging fast.

Q7What does a good test case contain?

An id, the requirement it checks, preconditions and test data, clear steps, and an expected result worked out before running. One condition per test case keeps failures easy to understand.

Q8How would you test a coupon that gives 10% off orders of $50 or more?

Test the boundary: $49.99 must be refused and $50.00 accepted with exactly $5.00 off. Then check rounding on an odd subtotal, case-insensitive codes, that a second coupon does not stack, and that the discount is dropped with a message if the cart later falls below $50.