CS24353 • MODULE 4

Module 4: Verification, Validation & Software Testing Methodologies

Topics 40 to 55 • Inspections, Static Analysis, McCabe Cyclomatic Complexity, Basis Path, Black-Box BVA & Reliability

Author: Shaswat Raj (BIT Mesra) Academic Year: 2024–25 (5th Sem CSE) Standard: IEEE & ISO/IEC Standards

Topic 20: Verification vs. Validation & Formal Review Techniques

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.

Fagan Inspection Process (6 Formal Steps)

  1. Planning: Moderator prepares inspection package, allocates roles (Author, Reader, Tester, Moderator).
  2. Overview: Author gives a brief orientation on the artifact scope.
  3. Preparation (Individual Review): Inspectors independently study the document to detect potential defects using checklists.
  4. Inspection Meeting: Reader paces through artifact line-by-line; defects are logged without debating solutions.
  5. Rework: Author corrects all logged defects.
  6. Follow-Up: Moderator verifies that all corrections are complete and correct before signing off.

Topic 21: White-Box Testing & McCabe's Cyclomatic Complexity

White-Box (Structural / Glass-Box) Testing derives test cases directly from the internal control-flow logic of the program code.

📐 McCabe's Cyclomatic Complexity $V(G)$ Mathematical Formulations

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!

🏛️ Solved Numerical 3: Control Flow Graph & Basis Path Testing Trace

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: }

Topic 22: Black-Box Testing Methodologies

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`.

Topic 23: Integration Testing Strategies & The Testing Hierarchy

  1. Unit Testing: Tests individual classes/functions in isolation (JUnit, pytest). Uses Mocks and Stubs.
  2. Integration Testing: Tests communication interfaces among integrated modules:
  3. System Testing: Tests the entire end-to-end system (Functional, Stress, Load, Security, Recovery, Alpha/Beta).
  4. Acceptance Testing (UAT): Final sign-off by real customer users before production rollout.

Topic 24: Software Reliability Engineering & Availability Mathematics

📐 Software Reliability & Operational Availability Formulas
🏛️ Solved Numerical 4: System Reliability & Availability Calculation

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\%}}$$

Topic 25: University Exam Problem Bank & Model Answers

Q8. Differentiate between Top-Down and Bottom-Up Integration Testing across Stubs, Drivers, and Defect Localization. (8 Marks)
DimensionTop-Down IntegrationBottom-Up Integration
DirectionFrom root control module downward to leaf modules.From primitive utility/data modules upward to root.
Test ScaffoldingRequires Stubs (simulated lower-level functions).Requires Drivers (simulated calling harnesses).
Major AdvantageEarly prototype demonstration of high-level UI workflows.Simplifies test case creation; verifies critical low-level algorithms first.
Defect LocalizationEasy for architectural flaws; difficult for low-level data errors.Extremely easy for localized hardware/data processing faults.
Q9. What is Regression Testing? Why is Test Suite Minimization Critical in Continuous Integration? (8 Marks)
Regression Testing is the selective re-execution of existing test cases to confirm that recent code modifications or bug fixes have not inadvertently broken previously working functionality.
• The CI Challenge: In large enterprise codebases with $50,000+$ test cases, running the entire suite on every git commit takes hours.
• Test Suite Minimization: Uses code coverage matrices and test prioritization heuristics to execute only the minimal subset of test cases affected by the modified code diff, keeping CI build times under 10 minutes while preserving $> 99\%$ defect detection capability!

Topic 46: Advanced White-Box Test Coverage Metrics & MC/DC

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.

Topic 47: Software Reliability Growth Models (SRGM)

During system testing, as defects are discovered and repaired, failure rate decays over execution time $t$:

📐 Jelinski-Moranda (JM) & Goel-Okumoto NHPP Reliability Models
🏛️ Solved Numerical 9: Goel-Okumoto NHPP Reliability Growth Calculation

In a system testing campaign, parameters are estimated as $a = 200 \text{ faults}$ and $b = 0.05 \text{ faults/day}$.

Topic 48: University Exam Problem Bank (Part II)

Q18. What is Mutation Testing? Define Mutation Score and Explain Equivalent Mutants. (8 Marks)
Mutation Testing assesses the quality and fault-detection power of a test suite by deliberately injecting artificial defects (mutants) into the source code:
1. Mutant Generation: Mutate arithmetic operators (`+` $\rightarrow$ `-`), relational operators (`<` $\rightarrow$ `<=`), or invert booleans.
2. Mutant Execution: Run test suite against mutant. If a test fails, the mutant is Killed; if all tests pass, the mutant Survives.
3. Mutation Score: $$\mathbf{\text{MS} = \frac{\text{Killed Mutants}}{\text{Total Mutants} - \text{Equivalent Mutants}} \times 100\%}$$
4. Equivalent Mutants: Mutants that are syntactically different but semantically identical to the original program (e.g., `for(int i=0; i<10; i++)` $\rightarrow$ `for(int i=0; i!=10; i++)`), making it mathematically impossible for any test case to kill them!
Q19. Explain Cause-Effect Graphing in Black-Box Test Case Design. (8 Marks)
Cause-Effect Graphing translates natural language specifications into formal boolean logic networks:
1. Causes: Distinct input conditions; Effects: Output actions or state changes.
2. Nodes are linked using standard boolean gates (AND, OR, NOT) and mutual exclusivity constraints ($E, I, O, R$).
3. The graph is converted systematically into a Decision Table, where redundant combinations are eliminated, generating the minimal set of comprehensive black-box test cases!

Topic 49: Modified Condition / Decision Coverage (MC/DC) Truth Table Derivation

In safety-critical avionics (DO-178C Level A), a complex decision $D = (A \lor B) \land C$ requires MC/DC test suite construction:

🏛️ Solved Problem 13: MC/DC Test Pair Construction ($N+1 = 4$ Test Cases)
Test #Condition $A$Condition $B$Condition $C$Decision Outcome $D$Independent Effect Verified
T1TrueFalseTrueTrueBase True Case
T2FalseFalseTrueFalse$A$ independently affects $D$ (Compare T1 vs T2: only $A$ flips!)
T3FalseTrueTrueTrue$B$ independently affects $D$ (Compare T2 vs T3: only $B$ flips!)
T4TrueFalseFalseFalse$C$ independently affects $D$ (Compare T1 vs T4: only $C$ flips!)
$$\mathbf{\text{Minimal MC/DC Test Suite: } \{T_1, T_2, T_3, T_4\} \quad (\text{Exactly } N+1 = 3+1 = 4 \text{ Test Cases!})}$$

Topic 50: Loop Testing Methodologies

Topic 51: Data-Flow Testing & Def-Use (DU) Anomaly Detection

Data-Flow Testing tracks the lifecycle states of variables across execution paths: Undefined ($U$), Defined ($D$), Referenced ($R$):

Data-Flow AnomalyAnomaly CodeSoftware Defect Manifestation
$UR$ AnomalyUndefined $\rightarrow$ ReferencedReading an uninitialized variable; garbage memory access or `NullPointerException`!
$DD$ AnomalyDefined $\rightarrow$ DefinedOverwriting a variable without using its previous value; dead computation/redundant assignment.
$DU$ AnomalyDefined $\rightarrow$ UndefinedVariable defined and then goes out of scope without ever being used; memory leak or logical omission.
🏛️ Solved Problem 17: 3-Value Boundary Value Analysis (BVA) for Date Validation

For month input $M \in [1, 12]$ and day input $D \in [1, 31]$:

🏛️ Solved Problem 24: Multiple Condition Coverage (MCC) vs MC/DC Comparison

For compound condition with $N = 4$ boolean inputs ($A \land B \lor C \land D$):

🏛️ Solved Problem 25: Musa Basic Execution Time Reliability Model

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}}$!

🏛️ Solved Problem 34: Boundary Value Analysis Worst-Case & Robust Worst-Case Test Set

For two integer variables $X \in [1, 10]$ and $Y \in [1, 5]$:

🏛️ Solved Problem 35: Smoke Testing vs Sanity Testing

• 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.

🏛️ Solved Problem 44: Complete White-Box MC/DC Avionics Verification Trace

For decision $D = (A \land B) \lor (C \land D)$ in Flight Control Software:

🏛️ Solved Problem 45: Goel-Okumoto NHPP Maximum Likelihood Parameter Estimation

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$!

🏛️ Solved Problem 54: Orthogonal Array Testing (OAT) Combinatorial Black-Box Testing

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!

🏛️ Solved Problem 55: Defect Removal Efficiency (DRE) Metric

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\%}}$$
🏛️ Solved Problem 64: Multiple Condition Coverage Independence Proof

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!

🏛️ Solved Problem 65: Automated Test Oracles & Metamorphic Testing

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))$!

🏛️ Solved Problem 73: Branch Coverage vs Condition Coverage Counterexample

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!

🏛️ Solved Problem 74: Automated Regression Test Prioritization (APFD Metric)

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!

🏛️ Solved Problem 85: Equivalence Class Partitioning Boundary Cases

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!

🏛️ Solved Problem 86: Stress Testing vs Load Testing vs Spike Testing

• 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)!

🏛️ Solved Problem 87: Code Coverage False Sense of Security

$100\%$ statement coverage does NOT guarantee bug-free software because it cannot detect Missing Logic / Omitted Code Paths or timing race conditions!

🏛️ Solved Problem 99: Gray-Box Testing Methodologies

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)!

🏛️ Solved Problem 100: Software Fuzz Testing & Chaos Engineering

• 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!

🏛️ Solved Problem 101: Test-Driven Development (TDD) Red-Green-Refactor Cycle
$$\text{1. Write Failing Test (Red)} \rightarrow \text{2. Write Minimal Code (Green)} \rightarrow \text{3. Refactor Code Architecture (Refactor)!}$$
🏛️ Solved Problem 113: Safety-Critical Software Hazard Analysis (FTA & FMEA)

• 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}$!

🏛️ Solved Problem 114: Automated Mutation Testing Operator Set

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!

🏛️ Solved Problem 115: Operational Profile-Based Statistical Software Testing

Allocate test cases proportionally to actual customer operational usage distributions ($80\%$ search, $15\%$ checkout, $5\%$ profile settings), maximizing MTTF in production environments!

🏛️ Solved Problem 125: Dynamic Symbolic Execution & Concolic Testing

Combines concrete execution with symbolic variables to systematically solve path constraints using SMT solvers, achieving $100\%$ branch coverage in deep nested conditionals!

🏛️ Solved Problem 126: Performance Testing Metrics (95th & 99th Percentile Latency)

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!

🏛️ Solved Problem 134: Model-Based Testing (MBT) with Extended Finite State Machines (EFSM)

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!

🏛️ Solved Problem 135: Automated Flaky Test Detection & Quarantine Strategies

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!

🏛️ Solved Problem 136: Security Fuzzing with American Fuzzy Lop (AFL) & AddressSanitizer

Using genetic algorithm feedback-directed coverage instrumentation to mutate input byte streams and detect memory corruptions (use-after-free, heap buffer overflow) within milliseconds!

🏛️ Solved Problem 141: MC/DC Decision Table for 4-Condition Avionics Logic

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!

🏛️ Solved Problem 147: Automated Combinatorial Pairwise Test Generation

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!

🏛️ Solved Problem 148: Chaos Engineering Steady-State Hypothesis Verification

Proving that terminating $30\%$ of microservice instances causes zero drop in transaction success rate ($> 99.99\%$) due to automated Kubernetes auto-healing!

🏛️ Solved Problem 155: Automated Security Vulnerability Testing (DAST vs SAST)

• 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!

🏛️ Solved Problem 156: Test Suite Minimization via Integer Linear Programming (ILP)

Formulating test selection as an ILP optimization problem to maximize branch coverage while minimizing total test execution wall-clock time!

🏛️ Solved Problem 163: Mutation Testing Operator Survival Analysis

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\%$!

🏛️ Solved Problem 164: Statistical Reliability Assessment via Operational Profiles

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!

🏛️ Solved Problem 169: Automated Fuzzing Feedback-Directed Loop Invariant Detection

Using symbolic path conditions and dynamic binary instrumentation to synthesize inputs that break complex nested pointer invariants in legacy C/C++ libraries!

🏛️ Solved Problem 170: Software Reliability MTTF & MTBF Derivations

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\%}$!