For the penalty() function and its flow graph in this topic, compute V(G) by all three formulas, list a basis set of paths and design one test case per path (EMI = ₹5,000).
Software testing executes a program to find defects and to show it meets its requirements. It combines static techniques (reviews, inspections, analysis) with dynamic testing at unit, integration, system and acceptance levels, using black-box and white-box designs such as boundary values and cyclomatic-complexity basis paths.
Glenford Myers (1979) defined testing as the process of executing a program with the intent of finding errors; in his view a good test case is one likely to expose an error nobody has found yet. Testing has two goals: to demonstrate to developer and customer that the software meets its requirements (validation testing), and to discover situations where its behaviour is incorrect or undesirable (defect testing). As Edsger Dijkstra put it, testing can show the presence of bugs but never their absence.
Both are achieved by static techniques, which examine artefacts without running them (reviews, walkthroughs, inspections, static analysis, formal verification), and dynamic techniques, which execute the software with test data. The vocabulary matters: a programmer's error (mistake) introduces a fault, also called a defect or bug; when the faulty code runs, the system may produce a failure — an observed deviation from expected behaviour. A test case specifies inputs, execution conditions and expected results; a test suite is a collection of them; a test harness (drivers, stubs, tools) runs them; and a test oracle is the mechanism — a person, a specification, a reference program — that decides whether an output is correct.
| Review type | Led by | Formality | Purpose |
|---|---|---|---|
| Informal review | Anyone (pair, buddy check) | None — no documented process | Cheap, quick feedback |
| Walkthrough | The author | Low to moderate | Author guides colleagues through the document or code; learning and finding defects |
| Technical review | A trained moderator or technical lead | Moderate; documented | Peers reach consensus on technical content and alternatives |
| Inspection | A trained moderator (not the author) | Highest — defined roles, entry/exit criteria, checklists, metrics | Find defects systematically and measure the process |
Fagan inspections (Michael Fagan, IBM, 1976) are the most formal review. Roles: moderator (plans and chairs), author, reader (paraphrases the work aloud), inspectors and a recorder/scribe. The process runs planning → overview → individual preparation → inspection meeting → rework → follow-up, using checklists of common error types (uninitialised variables, off-by-one loops, missing default cases, unchecked inputs). The meeting finds defects but does not fix them, and the author is not on trial. Inspections typically find a large share of defects before any test is run — IBM reported most defects being found this way — and they can check things testing cannot: standards, maintainability, incomplete code.
| Static-analysis check | Anomalies found |
|---|---|
| Control-flow analysis | Unreachable code, loops with multiple exits or entries |
| Data-use analysis | Variables used before initialisation, assigned twice with no use in between, declared but never used |
| Interface analysis | Mismatched parameter types or counts, functions never called, results never used |
| Information-flow analysis | Dependencies between input and output variables (for review) |
| Path analysis | The possible paths through the program and the statements on each |
| Storage management | Unassigned pointers, pointer arithmetic, memory leaks |
Unit (component) testing checks the smallest testable parts — functions, methods, classes — in isolation, usually by the developer. Because a unit cannot run alone, a driver (a test program that calls the unit and passes it data) and stubs (dummy versions of the modules it calls) are written. Testing a class thoroughly means calling every operation, setting and reading every attribute, and driving the object through all of its states.
Sommerville splits development testing into unit testing (individual units or object classes; focus on their functionality), component testing (units integrated into composite components; focus on component interfaces) and system testing (components integrated into the system; focus on component interactions). Interface types are parameter, shared-memory, procedural and message-passing interfaces, and interface errors fall into interface misuse, interface misunderstanding and timing errors.
| Integration strategy | How it works | Needs | Pros / cons |
|---|---|---|---|
| Big-bang | All modules combined at once and tested together | Nothing extra | Simple for tiny systems; faults very hard to locate |
| Top-down | Start with the top (control) module; add lower modules depth-first or breadth-first | Stubs for modules not yet integrated | Early skeleton demo, major control flaws found early; low-level details tested late |
| Bottom-up | Start with the lowest-level modules, combined into clusters (builds) | Drivers to call the clusters | Low-level utilities tested thoroughly; no working program until the end |
| Sandwich (hybrid) | Top-down for the upper layers and bottom-up for the lower layers, meeting in the middle | Both stubs and drivers | Combines the advantages; more effort to organise |
System testing checks the integrated system against its functional and non-functional requirements, end to end, usually by an independent test team; Sommerville's emphasis is on interactions — system testing confirms that the components fit together, cooperate as intended and exchange correct data when they should. Release testing tests a release intended for use outside the team, usually black-box (requirements-based, scenario and performance testing). Acceptance testing decides whether the customer accepts the system:
Black-box (functional, behavioural) testing derives tests from the specification, without looking at the code. Equivalence partitioning (EP) divides the input domain into classes whose members the program should treat the same way, then picks one representative from each class — both valid and invalid classes. For HLAMS annual income: EWS (₹1 – ₹3,00,000), LIG (₹3,00,001 – ₹6,00,000), MIG (₹6,00,001 – ₹12,00,000), HIG (above ₹12,00,000) are valid classes; zero or negative income and non-numeric input are invalid classes.
Boundary value analysis (BVA) complements EP: faults cluster at the edges of classes (off-by-one comparisons such as < instead of ≤), so tests are chosen at and next to each boundary — min, min+, nominal, max−, max. Under the single-fault assumption only one variable takes a boundary value at a time while the others stay nominal. Robust BVA adds the invalid values min− and max+; worst-case BVA drops the single-fault assumption and takes every combination.
Decision tables list conditions and actions; each column (rule) is one combination of condition values, so n binary conditions give up to 2ⁿ rules, which are collapsed using 'don't care' entries; each rule becomes a test. Cause–effect graphing (Myers) links causes (input conditions) to effects (outputs) with Boolean operators and constraints, and converts the graph into a decision table. State-transition testing derives tests from a state machine — every valid transition at least once, plus invalid events in each state (e.g. 'disburse' while an application is still under scrutiny must be refused). Use-case testing turns each scenario — main flow and alternatives — into end-to-end tests. Error guessing uses experience of typical mistakes, and pairwise testing covers every pair of parameter values with far fewer tests than all combinations.
White-box (structural, glass-box) testing derives tests from the program's internal structure. The structure is drawn as a control-flow graph (CFG): nodes are statements or basic blocks, edges are possible transfers of control, and a predicate node is one with two or more outgoing edges. Coverage criteria say how thoroughly the structure must be exercised:
| Criterion | Requirement | Notes |
|---|---|---|
| Statement coverage | Every statement executed at least once | Weakest criterion |
| Branch (decision) coverage | Every decision takes both its true and false outcome — every CFG edge traversed | Subsumes statement coverage |
| Condition coverage | Every atomic condition takes both true and false | Does not by itself guarantee branch coverage |
| Condition/decision coverage | Both condition and decision coverage | — |
| MC/DC | Each condition shown to affect the decision's outcome independently; at least N + 1 tests for N conditions | Required by DO-178C for the most critical avionics software |
| Multiple-condition coverage | All 2ᴺ combinations of the conditions in each decision | Thorough but expensive |
| Path coverage | Every distinct path through the program | Infeasible with loops; basis paths are the practical subset |
/* penal interest (rupees) on a late EMI */
double penalty(int daysLate, double emi, int isGovtEmployee)
{
double p = 0.0; /* node 1 (with the first test) */
if (daysLate > 0) { /* node 1: predicate */
if (daysLate <= 30) /* node 2: predicate */
p = emi * 0.01; /* node 3 */
else
p = emi * 0.02; /* node 4 */
if (isGovtEmployee) /* node 5: predicate */
p = p / 2; /* node 6 */
}
return p; /* node 7 */
} [1] daysLate > 0 ?
| T | F
v |
[2] daysLate <= 30 ? |
| T | F |
v v |
[3] [4] |
| | |
+---> [5] <--+ |
isGovtEmployee ? |
| T | F |
v | |
[6] | |
| v v
+------> [7] return pBasis-path testing (McCabe) uses V(G) as the number of tests: (1) draw the flow graph; (2) compute V(G); (3) find a basis set of linearly independent paths — each new path adds at least one new edge; (4) design a test case that forces each path, with its expected result. V(G) is an upper bound on the tests needed for branch coverage and a lower bound for full path coverage. As a quality measure, McCabe suggested keeping V(G) ≤ 10 per module; values above about 20 indicate complex, high-risk code and above 50 practically untestable code.
Data-flow testing (Rapps and Weyuker, 1985) selects paths by where variables are defined (given a value) and used (in a computation or a predicate). A def-use pair is a definition and a use it can reach without an intervening re-definition. Criteria in increasing strength: all-defs (every definition reaches at least one use), all-uses (every definition reaches every use it can reach) and all-du-paths. Data-flow testing finds faults such as using a value computed on the wrong branch.
| Loop type (Beizer) | Tests to run |
|---|---|
| Simple loop (maximum n passes) | Skip the loop; 1 pass; 2 passes; m passes (m < n); n − 1, n and n + 1 passes |
| Nested loops | Start with the innermost loop at simple-loop values while outer loops run the minimum; work outwards |
| Concatenated loops | If independent, test each as a simple loop; if the second depends on the first, treat them as nested |
| Unstructured loops | Redesign them into structured loops — they are too hard to test reliably |
Mutation testing (DeMillo, Lipton and Sayward, 1978) measures how good a test suite is. Small syntactic changes — mutants — are made to the program: replace > with ≥, + with −, a constant with another value, delete a statement. Each mutant is run against the suite; if some test now fails, the mutant is killed. Mutants that behave identically to the original for every input are equivalent and cannot be killed. The mutation score = killed ÷ (total − equivalent) × 100%; survivors show where new tests are needed.
Test-driven development (TDD), from Kent Beck's XP, turns testing into a design activity: write a small automated test for the next bit of functionality and watch it fail (red); write just enough code to pass it (green); then refactor while keeping all tests green. The resulting suite doubles as a regression suite and as executable documentation of how the code should behave.
| Type | What it checks | HLAMS example |
|---|---|---|
| Regression testing | Re-running previously passed tests after a change to check that nothing that worked is now broken | Full suite re-run after the rounding fix |
| Smoke testing | Quick, broad check of the most critical functions on a new build — is it stable enough to test further? (build verification test) | Can users log in, submit and pay? |
| Sanity testing | Narrow, focused check of particular functionality after a minor change or fix | Only the penalty calculation after a rule change |
| Performance testing | Response time and throughput at the expected load | Status query ≤ 2 s at 2,000 users |
| Load testing | Behaviour at expected and peak numbers of users or transactions | Last-day-of-scheme peak |
| Stress testing | Behaviour beyond the limits until the system breaks; graceful degradation and recovery | 10,000 users, then observe failure and recovery |
| Volume testing | Processing very large amounts of data | 10 lakh applications in the database |
| Endurance (soak) testing | Sustained load for hours or days, revealing memory leaks | Typical load for 72 hours |
| Security testing | Resistance to attack — vulnerability scans, penetration tests (e.g. OWASP Top 10: SQL injection, XSS) | Can an applicant read another's documents? |
| Usability testing | Real users perform real tasks; success rate, time, errors | Rural applicants complete the form on a phone |
| Compatibility testing | Different browsers, operating systems, devices and screen sizes | Chrome, Firefox, low-cost Android phones |
| Recovery testing | Forces failures and checks that recovery is correct and data intact (Pressman) | Kill the database server mid-posting |
| Installation / configuration testing | Install, upgrade and uninstall on target configurations | Fresh install in a district office |
| Accessibility testing | Use by people with disabilities (WCAG; GIGW for Indian government sites) | Screen-reader navigation of the portal |
Grey-box testing combines both views — black-box tests designed with some knowledge of internals (e.g. database structure). Exploratory testing is simultaneous learning, test design and execution in time-boxed sessions, valuable for finding the problems scripted tests miss. Ad-hoc or monkey testing feeds random input with no plan.
IEEE 829 (Standard for Software and System Test Documentation; 1983, revised 1998 and 2008, now succeeded by ISO/IEC/IEEE 29119-3) defines the test documents: test plan, test design specification, test case specification, test procedure specification, test item transmittal report, test log, test incident report and test summary report. A test plan states the test items, features to be tested and not tested, approach, pass/fail criteria, suspension and resumption criteria, deliverables, tasks, environment, responsibilities, staffing and training, schedule, risks and contingencies, and approvals.
Test case ID : TC-08
Title : Reject an applicant older than the maximum age
Requirement : FR-LN-01 (age 21–60) <- traceability
Priority : High
Pre-conditions : Applicant registered; scheme LIG-2026 open
Test data : Date of birth giving age 61 on the application date
Steps : 1. Log in as applicant 2. Open scheme LIG-2026
3. Enter details and submit
Expected result : Application rejected with 'Age must be between 21 and 60'
Actual result : (recorded during execution)
Status : Pass / Fail Executed by, date: ...import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class EmiServiceTest {
private final EmiService service = new EmiService();
@Test
void emiForTypicalLoan() throws Exception {
assertEquals(8997, service.emi(1000000, 9.0, 240));
}
@Test
void zeroInterestSplitsPrincipalEvenly() throws Exception {
assertEquals(5000, service.emi(120000, 0.0, 24));
}
@Test
void tenureAbove240IsRejected() {
assertThrows(InvalidLoanDataException.class,
() -> service.emi(1000000, 9.0, 241));
}
}Debugging follows a failed test. Pressman describes three approaches: brute force — memory dumps, run-time traces and print statements, letting the computer find the error (the most common and least efficient); backtracking — start where the symptom appears and trace the code backwards by hand until the cause is found (practical for small programs); and cause elimination — induction or deduction with binary partitioning: form a hypothesis about the cause, use data to prove or disprove it, and halve the search space each time (git bisect does this over a project's commit history). Every fix is followed by regression testing.
Try the problem first, then reveal the working one step at a time.
For the penalty() function and its flow graph in this topic, compute V(G) by all three formulas, list a basis set of paths and design one test case per path (EMI = ₹5,000).
HLAMS accepts applicants aged 21–60 and loan amounts from ₹1,00,000 to ₹25,00,000 (whole rupees). Generate (a) normal BVA tests, (b) robust BVA tests, and state the worst-case BVA count.
Annual income decides the category: EWS ₹1–₹3,00,000; LIG ₹3,00,001–₹6,00,000; MIG ₹6,00,001–₹12,00,000; HIG above ₹12,00,000. Design EP tests, then add boundary tests between categories.
Rules: an applicant outside the age limits is rejected; if age is fine but documents are not verified, documents are requested; if both are fine, the loan is sanctioned unless the applicant has a previous default, in which case the case is referred to the committee. Build and collapse the decision table, and derive the tests.
Compute V(G) for the function below and list a basis set of paths: int countOverdue(const int dues[], int n, int limit) { int i = 0, c = 0; while (i < n) { if (dues[i] > 0 && dues[i] <= limit) c++; i++; } return c; }
A form has three independent numeric inputs. How many test cases do normal BVA, robust BVA, worst-case BVA and robust worst-case BVA need?
HLAMS release 2 (32 KLOC) had 120 defects found by reviews and testing before release, and users reported 30 more in the first six months. Compute the DRE and the post-release defect density. What does the DRE tell management?
A mutation tool creates 50 mutants of the penalty function; 5 are equivalent and the suite kills 36. Compute the mutation score. One surviving mutant changes 'daysLate <= 30' to 'daysLate < 30'. Which single test kills it?
Main module M calls Portal P and LoanService L; L calls EmiCalculator E and Repository R. Describe top-down (depth-first) and bottom-up integration orders, naming every stub or driver needed.
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.