Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 60 ยท Testing Fundamentals

What Is Software Testing?

Learn what software testing is, how errors, defects and failures differ, why late defects cost more, and what testing can and cannot prove.

Every program you use was written by people, and people make mistakes. A tired developer misreads a requirement, a rule is copied with one number wrong, two features that work alone break when they meet. Software testing is the activity of checking a product on purpose, before real users do it for you, to learn how good it is and where it falls short.

This track teaches testing as a craft: how to think about it, how to design good checks, how to report problems and how a team organizes the work. You do not need to write code to be a good tester, but the lessons use small JavaScript examples so you can see each idea run. The code is a stand-in for real products: the products you will test cannot run inside this page, so the examples show the mechanism in miniature and say clearly what is simplified.

What testing actually is

Testing is more than "running the program and clicking around". A useful definition has four parts:

  • Planned. You decide what to check and why, instead of wandering.
  • Comparing. You compare what the software does with what it should do (the expected result).
  • Investigating. You look for information: does it work, how fast, how safely, how easily?
  • Reporting. You tell the team what you found so that people can decide what to do next.

Testing has two flavors that work together. Dynamic testing runs the software and watches its behavior. Static testing examines documents and code without running them, for example reading a requirement and noticing it contradicts another one. The next chapter covers static testing in detail (Static vs Dynamic Testing); this lesson focuses on the shared ideas.

What a tester does

Plan Decide what is worth checking.
Check Run the product or review the document.
Compare Actual result against expected result.
Report Give the team facts to decide with.

Testing produces information, not quality by itself.

1 / 2

Error, defect, failure: three different words

People say "bug" for everything, but testers use sharper words because each one points at a different place in the story:

Term Meaning Example
Error (mistake) A human slip The developer thinks "up to 10 items" means "fewer than 10"
Defect (bug, fault) The flaw that the mistake leaves in the code or a document The check items < 10 instead of items <= 10
Failure Wrong behavior you can observe when the defect is executed The customer cannot add a tenth item to the cart

The chain runs like this: a person makes an error, which puts a defect into a work product, and when that defect is executed under the right conditions the user sees a failure. Two consequences follow:

  1. Not every defect causes a failure. A defect in code that never runs, or that only matters on a leap day, can sit hidden for years.
  2. Not every failure comes from a defect in the code. A cosmic ray flipping a bit, a full disk, a network outage or a misconfigured server can all make a correct program fail.

Finding the cause of a failure is called debugging. That is a developer activity. Testing finds failures (or defects directly, through reviews); debugging finds and removes the cause.

flowchart LR
  A["Error<br/>(human mistake)"] --> B["Defect<br/>(flaw in the product)"]
  B -->|"executed under the right conditions"| C["Failure<br/>(visible wrong behavior)"]
  C --> D["Testing finds it"]
  D --> E["Debugging fixes the cause"]

A mistake becomes a defect, a defect may become a failure, and testing is what makes the failure visible.

Seeing the chain in code

The function below should return the average of a list of scores. A developer made an error while writing the loop, and the defect is in its stopping condition. Run it: the checks show the failures, and the comments mark the defect.

JS A defect and the failures it causes

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The check helper is the whole idea of dynamic testing in four lines: run the code with chosen input, compare with the expected result you decided in advance, and report. All three failures come from one defect. The one-score test is the most telling: with a single score the loop never runs, so the result is 0.

Real testing tools such as Jest or JUnit are fancier versions of check, and later chapters link to them. The stand-in here is the idea, not any particular tool.

Why testing exists

Software is complex enough that nobody can keep every interaction in their head. Testing exists because:

  • People make mistakes, including skilled developers, analysts and designers.
  • Failures cost something. A wrong invoice loses money, a crashed checkout loses customers, a medical device error can harm people, a leaked password damages trust.
  • Quality is not automatic. Without checking, you only hope the product is good.
  • Confidence needs evidence. A manager deciding "can we release?" should rely on facts about what was and was not checked.

Testing also has smaller goals along the way: finding defects, preventing defects (testers reviewing requirements find problems before any code exists), providing information for decisions, and building confidence that the product meets its requirements and the law or contracts that apply to it.

The cost of finding defects late

A defect found while reading a requirement costs a conversation. The same defect found after release costs investigation, a fix, a new build, retesting, a deployment, maybe an apology to customers and some lost revenue. The later a defect is found, the more work already depends on it, so the more must be changed.

This is a rule of thumb, not an exact law, and the real ratios vary hugely by project. But the shape is dependable, and it is the reason for the principle "test early" you will meet in the next lesson. The stand-in below uses made-up multipliers to make the shape visible. It is a model with invented numbers, not measured data.

JS An illustrative cost-of-late-defects model

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Both teams had the same number of defects. The difference is when they discovered them. Change the numbers and the multipliers and see how sensitive the totals are; that is the point of a model, you can argue about the inputs but the direction stays the same.

What testing can and cannot prove

This is the most important idea in the lesson.

Testing can show that defects are present. One failing check is proof.

Testing cannot show that there are no defects. Passing checks only tell you that those particular checks passed on that particular build. Imagine a different bug in averageScore that only shows up for an empty list (it would divide by zero and return NaN). If none of your tests used an empty list, every test could pass while that defect stayed hidden.

Two honest statements follow:

  • "We ran 400 tests and they all passed" does not mean "the product is bug-free".
  • "We found no defects" can mean the product is good or that the tests were weak. A tester always asks which one.

So testers speak in terms of risk and confidence: what we checked, what we did not check, and what that means for the decision at hand. A good test report says both things.

Related idea: you cannot test everything, so you must choose. The seven testing principles explain how to choose sensibly.

Who tests, and when

Testing is not only for a separate "QA team". Developers test their own code (unit tests), testers design and run broader checks, product owners check that features match intent, and users find what everyone missed. Testing also happens continuously, from reading the first requirement to monitoring production. Later lessons cover how this fits into a software development life cycle.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A developer misreads a requirement and writes if (age > 18) where age >= 18 was intended. Which term describes the flawed line of code itself?

    The human slip was the error, the flawed line it left behind is the defect, and the failure is what a user observes when that line runs (an 18-year-old being rejected).
  2. 2. A server's disk fills up and a correct program starts returning error pages. What does this show?

    Failures can be caused by the environment (full disks, networks, configuration). Defects do not always cause failures and failures do not always trace to code defects.
  3. 3. A team ran 500 automated tests and all passed. What can you safely conclude?

    Testing can show the presence of defects but cannot prove their absence. Passing tests lower risk and raise confidence only for what they actually checked.
  4. 4. Why is a defect usually cheaper to fix when found in the requirements than after release?

    The later a defect is found, the more design, code, tests, data and customers depend on it. The exact ratio varies, but the direction is reliable.

Summary

  • Software testing is planned checking that compares actual with expected behavior and reports what it learns; it can be static (no execution) or dynamic (running the product).
  • An error (human mistake) leaves a defect (flaw), which can produce a failure (observable wrong behavior). Debugging is finding and removing the cause.
  • Not every defect causes a failure, and not every failure is caused by a code defect.
  • Defects found later usually cost much more to fix, which is why testing starts early.
  • Testing shows that defects are present; it can never prove that none remain, so testers talk about risk and confidence.

Next up: The Seven Testing Principles.