Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Software testing: objectives and need

Objectives and need of software testing: definitions, fundamental principles (why exhaustive testing is impossible; testing shows presence, not absence, of defects), measurable goals (find defects, build confidence, assess quality, reduce risk), basic formulas (defect density, DRE, MTTF) and exam-fo

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Software testing is the disciplined process engineers use to check that a program meets its requirements and is fit for use. Engineers use the objectives and the reasons for testing to decide what to test, how much effort to spend, and when software is safe to release.

Key ideas

Start by defining the basic words you will see in exam questions.

  • Software testing: a set of activities, carried out before release (and during development), whose purpose is to execute a program with the intent of finding differences between expected and actual behaviour. (Assumption: we have requirements or an oracle to judge correctness.)
  • Defect (or bug): an incorrect element of a software artefact (e.g., wrong code, wrong requirement) that can cause a failure when executed (IEEE: a flaw in a component or system that can cause it to fail).
  • Error (mistake): a human action that produces an incorrect result (e.g., misunderstanding a requirement, wrong design decision, or coding slip).
  • Failure: externally visible incorrect behaviour of the system caused by a defect during execution.
  • Verification: checking that the product was built correctly (conformance to specifications). Verification answers "Are we building the product right?" (assumption: a specification exists).
  • Validation: checking that the right product was built (meets user needs). Validation answers "Are we building the right product?" (assumption: user needs can be expressed as requirements or acceptance criteria).

Exact foundational statements and common theorems / principles used in university answers:

  1. Principle: "Testing shows the presence, not the absence, of defects." — exact phrasing commonly attributed in testing literature. This means: no finite set of tests can prove a program is defect-free; a successful test run increases confidence but does not prove correctness. (Assumption: the input space or program state space is sufficiently large so that not all behaviours are checked.)

  2. Theorem (Exhaustive testing impossibility): For non-trivial programs with large or infinite input/state spaces, exhaustive testing is infeasible.

Derivation (what to write in an exam):

  • Let the input domain have N distinct inputs and suppose each test needs t seconds to run and examine. Total testing time T = N·t.
  • If N is very large (for example N = 10^m or N = 2^k for k boolean flags), T quickly exceeds feasible project time. Example draw: compute N = 2^20 = 1,048,576; if t = 1 s, T ≈ 12 days; for 50 boolean flags N = 2^50 ≈ 1.13e15, T is impossible.
  • Conclusion: exhaustive testing is not possible for realistic software.
  1. Pesticide paradox (exact statement): Repeating the same tests over and over will eventually stop finding new defects; tests must be regularly reviewed and revised to continue being effective. (Assumption: faults have been removed for behaviours covered by existing tests.)

  2. Risk-based objective statement: Tests should be prioritized to cover the behaviours most likely to cause severe failures or those used most by customers. (Assumption: you can estimate risk from domain knowledge or metrics.)

What are the practical objectives of testing? State them one by one (use these in short notes):

  • Find defects: the primary objective — detect and locate faults so developers can fix them.
  • Assess quality: measure reliability, performance, usability vs the requirements.
  • Provide information to stakeholders: give objective evidence about product status to managers, customers and testers.
  • Prevent defects: feed test results back to earlier phases to improve design and code quality (assumption: process allows feedback).
  • Build confidence: enable informed release decisions by quantifying residual risk.
  • Reduce risk: lower the probability of critical failures in production.

When writing answers, link objectives to the need: why these objectives are required.

Why testing is needed (give exam-style reasons):

  • Software complexity (many modules, large codebases) makes informal checking unreliable.
  • Human errors in requirements, design and coding are inevitable.
  • Cost of failure can be high (financial loss, safety hazards, legal liability), so testing reduces these risks.
  • Maintenance and evolution: tests support safe change and regression checking.
  • Interactions between modules or with other systems create emergent faults not visible in unit-level work.

What to draw (diagram instructions for exams):

  • Draw a rectangle labelled "All program behaviours". Inside it draw two overlapping circles: left circle labelled "Tested behaviours", right circle labelled "Correct behaviours". The intersection is "Tested & correct". The portion of the right circle not overlapped shows "Correct but untested"; the left-only portion shows "Tested but incorrect" (failures observed). Label an area within the rectangle but outside both circles as "Untested behaviours (unknown)". This Venn-style diagram supports statements about confidence and residual risk.

Assumptions to state when arguing in answers:

  • There exists a specification or oracle to decide expected output for a test; without an oracle you can only observe, not decide correctness.
  • Time and resources are limited so tests must be prioritized.
  • Testers have domain knowledge to assess risk and design focused tests.

Formulas

DefectDensity = Number_of_defects / Size_of_module
Number_of_defects = count of defects found (unitless); Size_of_module = KLOC (thousand lines of code) or FP (function points). Typical unit: defects/KLOC. Applies when comparing modules or releases; beware of differences in counting.

DRE = Defects_found_before_release / (Defects_found_before_release + Defects_found_after_release)
DRE = Defect Removal Efficiency (unitless fraction, often expressed as %). Defects_found_before_release = defects found during development/testing; Defects_found_after_release = defects reported by users after release. Applies to measure effectiveness of the testing process for a release.

MTTF = Total_operational_time / Number_of_failures
MTTF = Mean Time To Failure; Total_operational_time in hours (h) or days; Number_of_failures is count (unitless). Applies for reliability estimates in operational profiling. Note: Some courses use MTBF for repairable systems; during software testing phases, MTTF as defined here is commonly used for simple failure-rate calculations.

TestCoverage = Number_of_items_executed / Total_number_of_items
TestCoverage is unitless fraction (e.g., statement coverage: executed statements / total statements). Applies depending on what items are counted (statements, branches, requirements).

Note: Counting KLOC or defects can vary by organisation; ask your reviewer to verify counting rules used in your course.

Worked examples

Example 1 (numerical, defect density and DRE): Problem: A module has 12 defects found during system testing. After release, users report 3 defects in the same module. The module size is 6 KLOC. Compute defect density and DRE.

Solution (numbered steps):

  1. Formula for defect density: DefectDensity = Number_of_defects / Size_of_module.
  2. Substitute numbers: Number_of_defects (before release) = 12. Some definitions use total defects found including post-release; here we compute pre-release density: DefectDensity = 12 / 6 = 2 defects/KLOC. Unit: defects/KLOC. Alternatively, if your course defines defect density using total defects (pre + post), it would be 15 / 6 = 2.5 defects/KLOC.
  3. Formula for DRE: DRE = Defects_found_before_release / (Defects_found_before_release + Defects_found_after_release).
  4. Substitute: DRE = 12 / (12 + 3) = 12 / 15 = 0.8 = 80%.

Final answers: Defect density = 2 defects/KLOC. DRE = 80%.

Example 2 (model long-answer: "Explain the objectives and need for testing, with reasons and an example of prioritisation"): Write a structured answer with an introduction, list of objectives, link to need, example and conclusion.

Model answer (what to write in exams):

  • Introduction: Define software testing and state the primary aim: to detect defects and increase confidence.
  • Objectives: List and briefly explain Find defects, Assess quality, Provide information, Prevent defects, Build confidence, Reduce risk. For each objective add one supporting sentence (e.g., "Find defects: testing exposes faults so developers can fix them before customers see failures").
  • Need: Explain complexity, human error, cost of failure, integration issues and maintenance needs, giving one short real-world example (e.g., banking transaction bug causing financial loss) to justify why testing is essential.
  • Prioritisation example: For a banking application prioritise tests for transaction processing and authentication (high risk) over cosmetic GUI fixes (low risk). Mention risk-based testing and the pesticide paradox as reasons to update tests.
  • Conclusion: Testing does not prove the absence of defects but reduces risk and provides decision data for release.

This model answer includes definitions, enumerated objectives with short justification, and an example of test priority.

Common mistakes

  • Confusing verification and validation or swapping their question answers.
  • Giving incomplete DRE/defect density answers without stating whether they include post-release defects.
  • Not stating assumptions (like existence of oracle or resource limits) when making claims about what testing can achieve.
  • Failing to connect objectives to why testing is needed (e.g., writing objectives as a list without explaining need from risk/cost perspective).
  • Incorrect units: writing defects per LOC instead of defects/KLOC when following common course conventions.

For your exam

Typical question types:

  • Short definitions (define testing, defect, verification, validation).
  • 5–10 mark short notes (objectives of testing, need for testing, pesticide paradox, exhaustive testing impossibility).
  • Long answers: evaluate the importance of testing, give a prioritisation strategy using risk-based testing.
  • Numerical problems: compute defect density, DRE, simple MTTF calculations with given data.
  • Diagrams: draw the tested vs untested vs correct behaviours Venn diagram and explain regions.

What full-marks answers include:

  • Precise definitions with bolded key term (in your answer write the key term first then definition).
  • Clear statement of principles (use the exact phrase about presence vs absence of defects).
  • Explicit assumptions and constraints (resource limits, oracle availability).
  • For numericals: show formulas before substitution, units and final result with units.
  • For diagrams: label each region and explain what it means in one sentence.

Quick check

  1. State the primary objective of software testing in one sentence.
  2. Why is exhaustive testing usually impossible? Give one numerical argument.
  3. Write the formula for Defect Removal Efficiency (DRE).

Answers: 1) To find defects and provide information about product quality and risks. 2) Because the input/state space grows exponentially; e.g., 50 boolean inputs give 2^50 ≈ 1.13e15 combinations, impossible to run in any realistic time. 3) DRE = Defects_found_before_release / (Defects_found_before_release + Defects_found_after_release).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?