Error vs defect vs failure vs root cause in ISTQB CTFL
A person makes an error (a mistake). The error produces a defect (also called a fault or bug) in a work product. When defective code runs, it may cause a failure: the system does not do what it should, or does something it should not. A root cause is the fundamental reason the problem occurred, per ISTQB's CTFL v4.0 syllabus.
How are errors, defects and failures linked?
The chain runs in one direction. A human makes an error. The error leaves a defect in something the person produced. If that defect is in code and the code runs, a failure may be observed.
The syllabus names typical reasons for errors: time pressure, tiredness, lack of adequate training, and complexity, whether in the work products, the processes, the infrastructure or the interactions.
Defects are not limited to source code. A requirements specification or a test script can contain one, and so can a supporting work product like a build file. An undetected defect in an early work product tends to be carried into the work products built on it.
Does every defect cause a failure?
No. Some defects cause a failure every time the code runs. Others cause a failure only in specific circumstances. Some never cause a failure at all. A routine can run in production for years before the one input that exposes its defect arrives.
Not every failure comes from a human error either. Environmental conditions can cause failures too. The syllabus example is firmware damaged by radiation or an electromagnetic field.
What is a root cause?
A root cause is the underlying reason a problem arose, for example the circumstances that made the error likely. Teams look for it with root cause analysis, usually after a defect has been found or a failure has happened. Addressing the root cause, for example by removing it, is expected to prevent similar defects and failures or make them less frequent.
Example: a new developer gets no training on an in-house library (root cause). He misunderstands what unit one of its functions expects (error). He writes a call that passes the wrong unit (defect). At run time a customer is charged the wrong amount (failure).
Where the exam catches people
Calling the wrong result on screen a defect: what you observe when the software runs is the failure. The defect is the flaw in the code or document behind it.
Calling the developer's misunderstanding a defect: the human mistake is the error. The defect is what the mistake left in the work product.
Believing code that has run for years without trouble has no defect: some defects cause a failure only in specific circumstances, and some never do.
Treating the error and the root cause as the same thing: the root cause is the situation that led to the error, such as missing training.
Believing every failure traces back to a human error: environmental conditions can also cause failures.