Topics 40 to 55 • Inspections, Static Analysis, McCabe Cyclomatic Complexity, Basis Path, Black-Box BVA & Reliability
Software Quality Engineering encompasses both static defect prevention and dynamic defect discovery:
| Dimension | Verification (Static Engineering) | Validation (Dynamic Execution) |
|---|---|---|
| Core Question | "Are we building the product right?" (Barry Boehm) | "Are we building the right product?" (Barry Boehm) |
| Execution Status | Evaluates artifacts without executing code. | Evaluates software by executing code with test inputs. |
| Techniques | Formal Inspections, Peer Walkthroughs, Static Analysis, Desk Checking. | Unit Testing, Integration Testing, System Testing, User Acceptance Testing (UAT). |
| Target Artifacts | SRS, Architecture Design Documents, Source Code, Test Plans. | Executable Binaries, Deployed Web/Mobile Applications. |
White-Box (Structural / Glass-Box) Testing derives test cases directly from the internal control-flow logic of the program code.
For a Control Flow Graph (CFG) $G$:
Significance: $V(G)$ defines the exact upper bound on the number of linearly independent paths required to achieve $100\%$ branch coverage!
Consider the following function calculating discounts:
1: void computeDiscount(int age, boolean isMember) {
2: if (age >= 60) {
3: discount = 0.20;
4: } else if (isMember) {
5: discount = 0.10;
6: } else {
7: discount = 0.0;
8: }
9: print(discount);
10: }
Black-Box (Behavioral / Functional) Testing designs test cases strictly from specifications without inspecting internal source code.
| Technique | Operating Methodology | Concrete Industry Application |
|---|---|---|
| Equivalence Class Partitioning (ECP) | Divides input domain into valid and invalid equivalence classes; selecting one representative from each class test the entire partition. | Input Age $[18, 60]$: Valid Class $\{25\}$, Invalid Low $\{-5, 12\}$, Invalid High $\{75\}$. |
| Boundary Value Analysis (BVA) | Tests values directly at, immediately above, and immediately below the boundaries ($min, min+, nom, max-, max$). | For range $[1, 100]$: Test $\{0, 1, 2, 50, 99, 100, 101\}$ ($4n+1$ robustness values). |
| Decision Table Testing | Constructs truth table mapping complex boolean input combinations to output actions. | Credit Card Approval based on Credit Score, Income, and Existing Debt. |
| State Transition Testing | Tests finite state machine state transitions triggered by valid/invalid input events. | ATM Card validation: `Idle` $\rightarrow$ `PIN Entered` $\rightarrow$ `Authenticated` vs. `Locked`. |
A cloud database cluster runs continuously. On average, it operates for $MTTF = 990\text{ hours}$ before encountering a crash. The automated failover and repair script restores operation with $MTTR = 10\text{ hours}$:
$$\text{MTBF} = 990 + 10 = \mathbf{1000 \text{ Hours}}$$ $$\mathbf{\text{Availability } A = \frac{\text{MTTF}}{\text{MTTF} + \text{MTTR}} = \frac{990}{990 + 10} = \frac{990}{1000} = \mathbf{0.990 = 99.0\%}}$$| Dimension | Top-Down Integration | Bottom-Up Integration |
|---|---|---|
| Direction | From root control module downward to leaf modules. | From primitive utility/data modules upward to root. |
| Test Scaffolding | Requires Stubs (simulated lower-level functions). | Requires Drivers (simulated calling harnesses). |
| Major Advantage | Early prototype demonstration of high-level UI workflows. | Simplifies test case creation; verifies critical low-level algorithms first. |
| Defect Localization | Easy for architectural flaws; difficult for low-level data errors. | Extremely easy for localized hardware/data processing faults. |
| Coverage Criterion | Formal Definition | Rigor & Industry Adoption |
|---|---|---|
| 1. Statement Coverage ($C_0$) | $$\frac{\text{Executed Statements}}{\text{Total Statements}} \times 100\%$$ | Weakest metric; can achieve $100\%$ while completely missing empty `else` branches! |
| 2. Branch / Decision Coverage ($C_1$) | $$\frac{\text{Executed Decision Outcomes (True/False)}}{\text{Total Decision Outcomes}} \times 100\%$$ | Standard baseline for commercial business applications. |
| 3. Condition Coverage | Evaluates every individual atomic boolean sub-condition to both True and False at least once. | Does not guarantee branch coverage due to boolean masking. |
| 4. Modified Condition / Decision Coverage (MC/DC) | Each decision takes all possible outcomes, each atomic condition takes all possible outcomes, and each condition is shown to independently affect the decision outcome. | Mandatory Standard in Avionics & Automotive (DO-178C Level A, ISO 26262 ASIL-D)! Requires only $N+1$ test cases for $N$ conditions. |
During system testing, as defects are discovered and repaired, failure rate decays over execution time $t$:
In a system testing campaign, parameters are estimated as $a = 200 \text{ faults}$ and $b = 0.05 \text{ faults/day}$.
In safety-critical avionics (DO-178C Level A), a complex decision $D = (A \lor B) \land C$ requires MC/DC test suite construction:
| Test # | Condition $A$ | Condition $B$ | Condition $C$ | Decision Outcome $D$ | Independent Effect Verified |
|---|---|---|---|---|---|
| T1 | True | False | True | True | Base True Case |
| T2 | False | False | True | False | $A$ independently affects $D$ (Compare T1 vs T2: only $A$ flips!) |
| T3 | False | True | True | True | $B$ independently affects $D$ (Compare T2 vs T3: only $B$ flips!) |
| T4 | True | False | False | False | $C$ independently affects $D$ (Compare T1 vs T4: only $C$ flips!) |
Data-Flow Testing tracks the lifecycle states of variables across execution paths: Undefined ($U$), Defined ($D$), Referenced ($R$):
| Data-Flow Anomaly | Anomaly Code | Software Defect Manifestation |
|---|---|---|
| $UR$ Anomaly | Undefined $\rightarrow$ Referenced | Reading an uninitialized variable; garbage memory access or `NullPointerException`! |
| $DD$ Anomaly | Defined $\rightarrow$ Defined | Overwriting a variable without using its previous value; dead computation/redundant assignment. |
| $DU$ Anomaly | Defined $\rightarrow$ Undefined | Variable defined and then goes out of scope without ever being used; memory leak or logical omission. |
For month input $M \in [1, 12]$ and day input $D \in [1, 31]$:
For compound condition with $N = 4$ boolean inputs ($A \land B \lor C \land D$):
Failure intensity $\lambda(\mu) = \lambda_0 (1 - \frac{\mu}{v_0})$ where initial intensity $\lambda_0 = 10 \text{ failures/CPU-hr}$ and total failures $v_0 = 100$. After observing $\mu = 50$ failures, $\lambda = 10(1 - 0.5) = \mathbf{5.0 \text{ Failures/CPU-Hour}}$!
For two integer variables $X \in [1, 10]$ and $Y \in [1, 5]$:
• Smoke Testing (Build Verification Test): Shallow wide execution verifying that the new build is stable enough to undergo formal deep testing ("Does the software catch fire when turned on?").
• Sanity Testing: Deep focused subset testing verifying that a specific bug fix or minor module change actually works as expected before release.
For decision $D = (A \land B) \lor (C \land D)$ in Flight Control Software:
Given observed failure timestamps $\{t_1, \dots, t_n\}$, log-likelihood $\ln L = \sum \ln(ab e^{-bt_i}) - a(1 - e^{-bt_n})$ is solved numerically via Newton-Raphson to yield unbiased estimates of total latent faults $a$ and detection rate $b$!
For a web form with 4 dropdown menus each containing 3 options: Full Cartesian testing requires $3^4 = 81$ test cases. Using an $L_9(3^4)$ Orthogonal Array, pairwise combinatorial coverage is achieved in strictly $\mathbf{9 \text{ Test Cases}}$, catching $> 85\%$ of all real-world interaction faults!
If $E = 160$ defects are found during development reviews/testing, and $D = 40$ defects are discovered by users in production:
$$\mathbf{\text{DRE} = \frac{E}{E + D} \times 100\% = \frac{160}{160 + 40} \times 100\% = \frac{160}{200} \times 100\% = \mathbf{80.0\%}}$$For decision `if (A || B) && C`: Prove that test pair $(T, F, T) \implies \text{True}$ and $(F, F, T) \implies \text{False}$ isolates condition $A$ as the sole independent cause of decision flipping, fulfilling FAA DO-178C Level A avionics requirements!
When an exact test oracle is unavailable (e.g., testing complex machine learning algorithms or graph isomorphism): Metamorphic Testing checks relations between multiple executions: $f(\text{rotate}(image)) == \text{rotate}(f(image))$!
For `if (A && B)`: Test cases $(T, T) \implies \text{True}$ and $(F, F) \implies \text{False}$ achieve $100\%$ branch coverage, but completely fail to test condition $A=T, B=F$ or $A=F, B=T$, proving why Condition Coverage is strictly required!
Average Percentage of Faults Detected (APFD) measures how rapidly a prioritized test suite detects all known faults: $\text{APFD} = 1 - \frac{TF_1 + \dots + TF_m}{n \cdot m} + \frac{1}{2n}$. High APFD $> 0.90$ provides rapid feedback to developers during continuous integration!
For input integer $X \in [10, 50]$: Define valid class $[10, 50]$, invalid low $(-\infty, 9]$, and invalid high $[51, \infty)$. Test representatives: $\{5, 25, 65\}$. Combined with BVA $\{9, 10, 11, 49, 50, 51\}$, catches $99\%$ of comparison operator errors!
• Load Testing: Verifies system behavior under expected normal peak traffic ($5,000 \text{ req/sec}$).
• Stress Testing: Pushes system beyond extreme limits until crash to observe graceful degradation and recovery ($50,000 \text{ req/sec}$).
• Spike Testing: Simulates instant $10\times$ traffic surges (e.g., Flash Sale / Black Friday)!
$100\%$ statement coverage does NOT guarantee bug-free software because it cannot detect Missing Logic / Omitted Code Paths or timing race conditions!
Gray-Box Testing combines black-box user inputs with partial internal knowledge (e.g., database schema, API logs) to design high-impact security vulnerability tests (SQL injection, XSS)!
• Fuzz Testing: Feeding millions of randomized, malformed byte streams into parsers to uncover buffer overflows and memory leaks.
• Chaos Engineering (Netflix Chaos Monkey): Deliberately terminating production microservice containers at random to prove fault tolerance!
• Fault Tree Analysis (FTA): Top-down deductive failure analysis using boolean logic gates to isolate single points of failure.
• Failure Modes and Effects Analysis (FMEA): Bottom-up inductive tabular analysis computing Risk Priority Number $\text{RPN} = \text{Severity} \times \text{Occurrence} \times \text{Detection}$!
Apply 5 core mutation operators: (1) Arithmetic Operator Replacement (`+` $\rightarrow$ `-`), (2) Relational Operator Replacement (`>` $\rightarrow$ `>=`), (3) Logical Operator Replacement (`&&` $\rightarrow$ `||`), (4) Statement Deletion, (5) Variable Replacement!
Allocate test cases proportionally to actual customer operational usage distributions ($80\%$ search, $15\%$ checkout, $5\%$ profile settings), maximizing MTTF in production environments!
Combines concrete execution with symbolic variables to systematically solve path constraints using SMT solvers, achieving $100\%$ branch coverage in deep nested conditionals!
Why average latency is deceptive: In a $100,000 \text{ req/sec}$ distributed system, a 99th percentile spike of $2\text{ seconds}$ degrades UX for 1,000 customers every second!
Automatically generating test sequences from formal statecharts using graph traversal algorithms (Chinese Postman Problem, Depth-First Search), guaranteeing $100\%$ state and transition coverage in embedded controllers!
Detect non-deterministic tests (flaky tests caused by asynchronous timeouts or unseeded RNGs) by re-running failed tests $10\times$ in isolation. Quarantining flaky tests prevents CI pipeline blockage while preserving developer trust!
Using genetic algorithm feedback-directed coverage instrumentation to mutate input byte streams and detect memory corruptions (use-after-free, heap buffer overflow) within milliseconds!
Construct the exact 5 test vectors for $D = (A \land B) \lor (C \land \neg D)$, isolating each condition independently to pass FAA DO-178C Level A audit!
Using the ACTS (Automated Combinatorial Testing for Software) tool to generate optimal 2-way and 3-way test suites catching $> 90\%$ of multi-variable interactions!
Proving that terminating $30\%$ of microservice instances causes zero drop in transaction success rate ($> 99.99\%$) due to automated Kubernetes auto-healing!
• SAST: Analyzes source code without execution to identify OWASP Top 10 vulnerabilities.
• DAST: Penetration tests running web binaries from the outside to catch active runtime configuration leaks!
Formulating test selection as an ILP optimization problem to maximize branch coverage while minimizing total test execution wall-clock time!
When a mutant survives (e.g., swapping `<=` to `<` on boundary): Construct a targeted boundary test vector $(x = 100)$ that exposes the mutant, driving the Mutation Score to $100\%$!
Computing operational MTTF by weighting component failure rates against real-world user interaction frequencies, ensuring maximum reliability where users spend $90\%$ of their session time!
Using symbolic path conditions and dynamic binary instrumentation to synthesize inputs that break complex nested pointer invariants in legacy C/C++ libraries!
For exponential failure distribution: $R(t) = e^{-\lambda t}$. Given failure rate $\lambda = 0.001 \text{ failures/hour}$, reliability at $t = 100 \text{ hours}$ is $R(100) = e^{-0.10} = \mathbf{90.48\%}$!