Knowledge / Computer Science and Engineering / Software testing basics

Software testing basics

Computer Science and Engineering (B.E./B.Tech) · Software engineering · free study notes for exams, placements and interviews

In short

Software testing is the planned execution and static examination of software to find defects, measure quality against requirements, and give stakeholders evidence about risk before release. It is not proof of correctness: testing can show the presence of defects but never their absence, so the whole discipline is about choosing a small, high-yield subset of the infinite possible inputs. It is examined in every Indian university software-engineering paper (AICTE/CBCS syllabi), in UGC-NET Computer Science, and in ISRO, BARC, DRDO and PSU written tests; note that software engineering was dropped from the GATE CSE syllabus in the 2021 revision, so confirm the current syllabus before preparing it for GATE. In placements it is the default area of questioning for QA/SDET roles at TCS, Infosys, Wipro, Cognizant, Accenture, Capgemini and LTIMindtree, and is asked of every developer as "how would you test this?"

Explained

Basic vocabulary and the testing principles

Static testing and reviews

Levels of testing and integration strategies

  1. Unit (component) testing - smallest testable unit (function, class, module), usually by the developer, with stubs (called-by dummy) and drivers (calling dummy). Checks internal logic, boundary values, error handling.
  2. Integration testing - interfaces and interactions between units.
    • *Big bang* - everything assembled at once; cheap to set up, hard to localise faults.
    • *Top-down* - from the main control module downwards; needs stubs; finds design/control defects early, demonstrates a skeleton product early; lower-level utilities tested late.
    • *Bottom-up* - from utilities upwards; needs drivers; good for critical low-level logic; no working system until late.
    • *Sandwich (hybrid)* - both ends meet at a target layer; common in large systems.
    • *Incremental / continuous integration* - one module added at a time against a working build.
  3. System testing - the complete integrated system against the SRS, on a production-like environment: end-to-end functional flows plus non-functional characteristics.
  4. Acceptance testing - against user needs and contract. Forms: UAT by business users, contract and regulatory acceptance (RBI, SEBI, IRDAI, NPCI certification for UPI apps), operational acceptance (backup, restore, failover, patching), alpha (in-house, developer site) and beta (real users, their own environment).
  5. These levels map to the right-hand arm of the V-model: unit tests to module design, integration to high-level design, system to the SRS, acceptance to user requirements - each test level planned when the corresponding document is written.

Black-box (specification-based) test design

White-box (structure-based) testing and coverage

Types of testing (what quality attribute is targeted)

STLC, documentation, defects and metrics

Key points

Formulas and examples

V(G) = E − N + 2P - cyclomatic complexity; E = edges, N = nodes of the CFG, P = connected components (P = 1 for one program). Also V(G) = (number of predicate/decision nodes) + 1, and = number of enclosed regions + 1 in a planar CFG. Unitless.
Statement coverage % = (statements executed / total executable statements) × 100; Branch coverage % = (branch outcomes exercised / total branch outcomes) × 100; Path coverage % = (paths executed / total feasible paths) × 100
Defect density = total defects / size, size in KLOC (thousand lines of code) or function points - defects per KLOC
Defect Removal Efficiency DRE = Dt / (Dt + Dp) × 100 - Dt = defects found before release, Dp = defects found by users after release
Defect leakage = Dp / (Dt + Dp) × 100; Test case effectiveness = defects detected by test cases / total defects × 100
BVA test counts: 4n + 1 (single-fault BVA), 6n + 1 (robust), 5ⁿ (worst case), 7ⁿ (robust worst case), n = number of input variables
Mutation score = killed mutants / (total mutants − equivalent mutants) × 100
MTBF = MTTF + MTTR (hours); Availability = MTTF / (MTTF + MTTR) = MTTF / MTBF, unitless (×100 for %); Reliability R(t) = e−λt with failure rate λ = 1/MTTF per hour
Test execution % = executed / planned × 100; Pass rate % = passed / executed × 100

Example 1 - Cyclomatic complexity, basis paths and coverage.

int grade(int m){
  if (m < 0 || m > 100) return -1;   /* d1 */
  if (m >= 90) return 1;             /* d2 */
  else if (m >= 75) return 2;        /* d3 */
  else if (m >= 40) return 3;        /* d4 */
  return 4;
}

Example 2 - EP and BVA for a job-portal field. "Age" accepts integers 18 to 60 inclusive.

Example 3 - Decision table for login. Conditions: C1 valid user ID, C2 valid password, C3 account locked → 2³ = 8 rules, collapsed to 4 test cases (the don't-care entries cover all 8).

RuleC1 valid IDC2 valid passwordC3 lockedAction
R1N––Reject: "invalid credentials", increment attempt counter
R2YN–Reject: "invalid credentials", increment counter; lock on 3rd failure
R3YYYReject: "account locked, contact admin"
R4YYNGrant access, reset counter

Example 4 - Defect metrics for a release. Module size 25,000 LOC = 25 KLOC. Testing found 150 defects; users reported 18 in the first three months. 1,200 test cases planned, 1,080 executed, 950 passed.

Example 5 - Reliability and availability of a tested server application. Observed 2,000 hours of operation, 8 failures, average repair time 1.5 hours.

Black-boxWhite-box
BasisSpecification, requirementsSource code, control/data flow
Tester needsDomain knowledgeProgramming knowledge
FindsMissing/wrong functionality, interface defectsDead code, logic and loop errors, untested paths
Cannot findUntested internal pathsMissing requirements
TechniquesEP, BVA, decision table, state transition, pairwiseStatement/branch/MC-DC coverage, basis path, data flow, mutation
Typical levelSystem, acceptanceUnit, integration
CaseSeverityPriority
Payment debits twice, rare edge caseHighHigh
App crashes on an unsupported legacy browserHighLow
Company name misspelt on home pageLowHigh
Tooltip misaligned on an internal admin screenLowLow

Where it is used

Interview questions

Common mistakes

Related topics

Test automation and TDD · SDLC and Agile · Requirements engineering and UML · Clean code and code reviews · Software project management and estimation · Low-level design (object-oriented design) interviews

Open in the Knowledge reader →Find jobs →