SoftwareTesting COMPLETE Notes
SoftwareTesting COMPLETE Notes
Week 1 L1–L5 Introduction, Error/Fault/Failure, Testing Levels, Basic Concepts, Unit Testing
Week 2 L6–L10 Black Box: EC Partitioning, BVT, Special Value, Decision Table, Pairwise, White
Box Intro
Week 3 L11–L15 MC/DC Testing, Path Testing, Cyclomatic Complexity, Dataflow, Mutation Testing
Week 4 L16–L20 Integration Testing, System Testing, Regression Testing, OOP Testing
Sabse pehle samjhte hain ki software testing kyun zaroori hai. Jab bhi koi programmer code likhta hai,
galtiyan hoti hain — ye inevitable hai. Chahe naya programmer ho ya 20 saal ka experienced developer,
mistakes hoti hain. In mistakes ki wajah se program galat kaam karta hai. Testing ka kaam hai — in mistakes
ko release se pehle dhundh kar theek karna.
Real life example: Ariane 5 Rocket (2000) — launch ke sirf 37 seconds baad self-destruct ho gaya. Ek bug
ki wajah se. 64-bit processor pe overflow hua jo 32-bit machine ke purane code se aaya tha. Exception
handler disable tha. Total loss: $1 Billion se zyada!
■ DHYAN DO: Testing agar na ki jaaye toh companies ko crores-arabao ka nuksan ho sakta hai. Iska ek
real proof Ariane 5 hai.
PARIBHASHA — Error ya Mistake: Programmer ki galti — yeh human action hai. Jab programmer code
likhta hai aur kuch galat likhta hai, use error kehte hain. Example: 'result = i * j' likhna tha, galti se 'result = i
* 2' likh diya.
PARIBHASHA — Fault ya Bug ya Defect: Code mein actual problem — error ki wajah se code mein jo
galati aati hai. Yeh PRODUCT mein hoti hai, programmer ke dimaag mein nahi. Example: Code mein 'i * 2'
hai jo wrong answer deta hai jab j != 2 ho.
PARIBHASHA — Failure: Program ka runtime pe expected behavior se alag behavior dikhana. Jab fault
execute hota hai aur wrong output ya crash aata hai. Example: Program galat result print karta hai.
■ NOTE: Yeh chain ZAROOR nahi hai! Har error fault nahi banati. Har fault failure nahi dikhata.
Error Mistake Programmer ke mind mein, i*2 likhna jab i*j chahiye tha
during coding
Fault Bug, Defect Code mein (product mein) Code mein i*2 hai jo kabhi wrong dega
Failure Crash, Wrong Runtime pe visible hoti hai Program galat answer print karta hai
output
■ EXAM QUESTION: Error aur Fault mein kya fark hai? Kya har error se fault banti hai? Example
do.
■ ANSWER: Error = programmer ki galti (human action). Fault = code mein resulting defect (product
defect). Nahi — har error fault nahi banati. Example: Programmer 'i*j' ki jagah 'i*2' likhta hai (error).
Lekin agar j=2 tha already, toh program sahi hi kaam karta hai — fault nahi bana. Agar j=5 hota toh fault
ban jaata.
■ EXAM QUESTION: Failure kab hoti hai? Kya har fault se failure zaroor hoti hai?
■ ANSWER: Failure tab hoti hai jab fault wala code execute hota hai aur wrong behavior dikhta hai.
Nahi — har fault failure nahi dikhata. Agar test case woh faulty code path kabhi execute hi na kare,
failure kabhi nahi dikhegi. Ya fault itna minor ho ki output phir bhi acceptable lag raha ho.
Fact Detail
Experienced programmers mein bugs Average 50 bugs per 1000 lines of code — research se proven
After extensive testing Phir bhi ~1 bug per 1000 lines release time pe bachi rehti hai
Testing effort Companies apna 50%+ effort sirf testing mein lagate hain
Testing time Effort 50% lekin time sirf 10% development cycle ka — high parallelism
■ EXAM TIP: 50 bugs per 1000 LOC — yeh number exam mein aa sakta hai. Experienced programmers
bhi galtiyan karte hain — isliye testing hamesha zaroori hai.
1. Review / Code, design ya specification Static (code execute Har stage — requirement, design,
Inspection manually read karke bugs dhundna. nahi hota) code
Team meeting mein hota hai.
2. Static Analysis Automated tools code run kiye bina Static Coding phase
analyse karte hain. Compiler
warnings bhi isi category mein hain.
3. Simulation Real hardware unavailable ho toh Dynamic (execute When real environment not
simulate karke test karte hain. hota hai) available
■ NOTE: Sirf ek technique kaafi nahi — alag techniques alag types ke bugs pakdti hain. Isliye Pesticide Effect
samajhna zaroori hai (Lecture 3 mein).
Check karta hai: Code vs Design, Design vs Check karta hai: Final product vs SRS requirements
Specification
Kaun karta hai: Testers
Kaun karta hai: Developers
Kab: End mein — System Testing phase
Kab: Development lifecycle ke dauraan, har stage mein
Type: Only Dynamic (execute karke)
Type: Static + Dynamic dono
Example: System testing, acceptance testing
Example: Code review, unit testing, integration testing
■ EXAM TIP: TRICK: Verification = 'V for Validate process' (sahi process?). Validation = 'V for Value
delivery' (sahi product?). Unit Testing = VERIFICATION. System Testing = VALIDATION.
■ EXAM QUESTION: Verification aur Validation mein kya fark hai? Unit testing kaunsa hai?
■ ANSWER: Verification: 'Sahi bana rahe hain?' — code ko design ke against check karna. Developers
karte hain. Static+Dynamic. Validation: 'Sahi cheez banai?' — final product ko SRS requirements ke
against check karna. Testers karte hain. Only Dynamic. Unit Testing = VERIFICATION (code vs
detailed design check karna).
Testing sirf ek baar nahi hoti — software development ke alag-alag stages pe alag-alag levels ki testing hoti
hai. Yeh levels ek sequence mein follow hoti hain.
■ DHYAN DO: Sequence ZAROOR follow karo: Unit → Integration → System → Acceptance. Yeh order
exam mein poochha jaata hai!
• Pehle chhote pieces test karo (units) — bugs early mein pakad lo
• Phir saath mein kaam karne wale pieces test karo (integration)
• Phir poora system test karo against requirements
• Finally customer check karta hai
Sochte hain: agar har unit individually sahi kaam kar raha hai, toh saath mein kyun nahi karenge? Kyunki
interface mein problems ho sakti hain:
• Function A integer expect karta tha, Function B ne float bheja → type mismatch
• Parameters galat order mein bheje gaye → (name, age) ki jagah (age, name)
• Shared global variable ek module ne change ki, doosre ko pata nahi → data inconsistency
Alpha Testing Developer ki office/lab mein Developer team ke log Internal testing before release
Beta Testing Selected friendly customers Trusted external users Real-world testing with actual users
ke paas
■ EXAM TIP: Alpha = Developer site. Beta = Selected customers. Acceptance = Customer khud. Yeh
yaad karo sequence mein.
■ EXAM QUESTION: Testing ke 4 levels list karo. Integration testing unit testing se alag kyun karte
hain?
■ ANSWER: 4 levels: Unit Testing → Integration Testing → System Testing → Acceptance Testing.
Integration testing alag isliye: Units individually sahi ho sakti hain lekin interface errors tab bhi ho sakti
hain — wrong parameter types, wrong order, shared data issues. Unit testing sirf individual behavior
check karta hai, interface nahi.
• Each bug removal step (review/testing) sirf ~30% bugs detect karta hai
• Matlab: 70% bugs escape karte hain har ek filter se!
■ NOTE: Agar har technique sirf 30% effective (Capers Jones ke anusaar) hoti: 1000 x (0.7)^4 = 1000 x 0.24 =
240 bugs survive hote. Isliye multiple diverse techniques use karna zaroori hai!
■ EXAM QUESTION: Pesticide Effect kya hai? Calculate karo: 500 bugs hain, 4 techniques use ki,
har ek 60% effective. Kitne bugs bachenge?
■ ANSWER: Pesticide Effect: Ek hi technique baar baar use karne se bugs us technique se resistant
ho jaate hain. Capers Jones: har step ~30% bugs pakdta hai. Calculation: 500 x (1-0.60)^4 = 500 x
(0.40)^4 = 500 x 0.0256 = 12.8 ≈ 13 bugs survive.
PARIBHASHA — Test Case: Ek triplet: (I, S, O) — Input data + System state at input + Expected output.
Sirf input nahi, poori context.
PARIBHASHA — Test Suite: Saare test cases ka collection — complete set of tests.
S = System State (program kis state mein hai jab input dete hain)
Check: Correct behavior for valid input Check: Graceful handling of bad input
Example: Valid book ID return karna Example: Already returned book ko return karna
Purpose: Happy path verify karna Purpose: Error handling verify karna
■ EXAM QUESTION: Test Case aur Test Data mein kya fark hai? Library software ke liye ek test
case likho.
■ ANSWER: Test Data = sirf input values. Test Case = triplet (I, S, O): input + state + expected output.
Library example — Issue Book: State=book available hai aur member valid hai, Input=book_id='CS101',
Expected Output='Book issued successfully', issue record created, book status='Issued'.
Type Matlab Kya Hai Code Basis Kab Use Karte Hain
Dekhna?
Black Box Testing Sirf input-output behavior Nahi Specification / Functional testing, user
test karo — code ki koi Requirements perspective
knowledge nahi
White Box Testing Code structure examine Haan Source Code Code coverage, developer
karke test karo — internal testing
paths cover karo
Grey Box Testing Design dekhte hain (internal Partial Design Documents Integration testing, API testing
structure partially known)
• Black Box alone ki problem: Programmer ne kuch extra code likha jo specification mein nahi tha —
black box se woh code kabhi execute nahi hoga (unreachable code). Aur woh code malicious bhi ho
sakta hai!
• White Box alone ki problem: Specification mein kuch mention tha jo code mein implement hi nahi hua
— white box se yeh detect nahi hoga kyunki woh feature hi nahi hai code mein.
• Conclusion: DONO complementary hain — ek doosre ke gaps fill karte hain.
■ DHYAN DO: Exam trap: 'Kya white box testing ho toh black box ki zaroorat nahi?' — GALAT! Dono
zaroori hain aur alag-alag types ke bugs pakdte hain.
Step-by-step Process:
Assumption: Detection rate same hai for seeded aur original bugs
Example:
• Matlab: Testing ke baad bhi ~75 - 45 = 30 original bugs abhi bhi code mein hain
■ DHYAN DO: ASSUMPTION: Seeded bugs ka difficulty level SAME hona chahiye original bugs jaisa.
Too easy seeds → overestimate. Too hard seeds → underestimate. Yeh assumption exam mein poochhi
jaati hai!
■ EXAM QUESTION: Error seeding formula explain karo. 200 bugs seeded, 150 detect hue. 90
original bugs mili. Remaining bugs estimate karo.
■ ANSWER: Formula: N = (n x S) / s. n=90 original bugs found, S=200 seeded, s=150 seeded
detected. N = (90 x 200) / 150 = 120 estimated total original bugs. Remaining = 120 - 90 = 30 bugs still
in code.
Unit ki definition:
• Ek function ya method
• Ek module ya class
• Ek procedure
• Basically: sabse chhoti independently testable piece of software
Ek unit doosri units ke saath interact karti hai — woh call karta hai aur woh bhi call hota hai doosron se. Agar
saari dependencies real hain toh isolated test nahi kar sakte. Solution: Driver aur Stub!
PARIBHASHA — Stub: Woh software jo un functions ko SIMULATE karta hai jo test unit CALL karti hai
lekin abhi ready/available nahi hain. Unit ke neeche hota hai logically.
DRIVER
(Caller simulate karta hai)
|
| call karta hai
v
+--------------------+
| UNIT UNDER TEST | <-- yeh test ho raha hai
+--------------------+
|
| call karta hai
v
STUB
(Called function simulate karta hai)
Top-level unit (koi caller nahi) Haan — Driver Nahi Koi upar nahi jo ise call kare
banao
Bottom-level unit (koi called Haan — Driver Nahi Khud kisi ko call nahi karta
function nahi) banao
Middle-level unit Haan — Driver Haan — Stub Dono taraf se interact karta hai
banao banao
■ EXAM TIP: Driver = Caller simulate karna (Unit ke UPAR se call karta hai). Stub = Called function
simulate karna (Unit ke NEECHE wala function). Bottom-Up testing mein Drivers chahiye. Top-Down
mein Stubs.
■ EXAM QUESTION: Driver aur Stub mein kya fark hai? Ek middle-level function ke liye kya
chahiye?
■ ANSWER: Driver = caller unit ka simulator — unit ko call karta hai aur test data deta hai. Stub =
called function ka simulator — canned responses return karta hai. Middle-level function ke liye DONO
chahiye: driver (upar se call karne ke liye) aur stub (neeche ke functions simulate karne ke liye).
Black Box Specification / detailed Input-output behavior ke anusaar test cases design karo
design
White Box Source code Code paths, branches, conditions cover karo
Grey Box Design documents (partial Design se test cases, code dekhe bina
internal knowledge)
Black Box testing mein input domain ko systematically partition karte hain. Do most important techniques:
Equivalence Class Partitioning (ECP) aur Boundary Value Testing (BVT).
• Ek function 1 se 1000 tak integers accept karta hai — kya 1000 test cases likhein?
• Nahi! Sab values ek jaisa behave karti hain → sirf EK test case kaafi hai
• Similarly invalid values (0, -1, 1001) bhi ek jaisi fail hongi → EK invalid test case
Range a to b 1 valid: a <= x <= b 2 invalid: x < a aur x > Age range 1-100: valid={50}, invalid={-5,
b 150}
Specific single value 1 valid: x = that value 1 invalid: x != value Pin='1234': valid={'1234'}, invalid={'9999'}
Member of set {a,b,c} 1 valid: x ∈ {a,b,c} 1 invalid: x ∉ {a,b,c} Day ∈ {Mon,Tue}: valid={Mon}, invalid={Xyz}
Boolean condition 1 valid: condition true 1 invalid: condition hasPassword: valid={yes}, invalid={no}
false
Enumerated type 1 valid per valid value 1 invalid Status ∈ {A,B,C}: valid ECs for A,B,C
separately
Weak EC Testing Ek test case mein har EC se ek max(valid ECs, Quick basic testing
value lo (min combinations) invalid ECs)
Strong EC Testing Saare ECs ka Cartesian product — Product of all EC Thorough testing with
har combination counts interactions
Weak Robust Testing Weak + invalid ECs bhi include karo Moderate count When error handling important
Strong Robust Testing Strong + saare invalid ECs ka Maximum — most Safety-critical systems
combination exhaustive
Scenarios identify karne ke liye OUTPUT dekho — different outputs = different ECs:
■ EXAM TIP: ECs identify karne ka shortcut: Different OUTPUT scenarios dekho — jo alag output deta
hai woh alag EC hai! Input domain se zyada output behavior pe focus karo.
Education ECs: EC_school = School, EC_ug = UG, EC_pg = PG, EC_inv = None
• Weak EC: max(2 age ECs, 3 edu ECs) = 3 test cases: (15,School), (35,UG), (25,PG)
• Strong EC: 2 x 3 = 6 test cases — all combinations: (15,School), (15,UG), (15,PG), (35,School),
(35,UG), (35,PG)
■ EXAM QUESTION: Function ek phone number accept karta hai: area code (200-999) aur 7-digit
number. Equivalence Classes design karo.
■ ANSWER: Area code ECs: Valid={200-999}, Invalid1={<200}, Invalid2={>999},
Invalid3={non-numeric}. Number ECs: Valid={7-digit number}, Invalid1={<7 digits}, Invalid2={>7 digits},
Invalid3={non-numeric}. Weak EC test cases: valid combo (e.g., 555-1234567), each invalid type = ~6
test cases total.
• Programmer likhna chahta tha: if (age <= 18) — galti se likha: if (age < 18)
■ DHYAN DO: TOTAL 7 TEST VALUES for any range! Exam mein agar range di ho, directly yeh 7 values
likho: min-1, min, min+1, mid, max-1, max, max+1.
■ EXAM QUESTION: Function accepts salary in range [10000, 100000]. BVT test values list karo.
■ ANSWER: 7 values: 9999 (just below min-invalid), 10000 (lower boundary-valid), 10001 (just above
min-valid), 55000 (nominal-valid), 99999 (just below max-valid), 100000 (upper boundary-valid),
100001 (just above max-invalid).
PARIBHASHA — Special Value Testing: Experienced tester ki intuition aur knowledge se specific values
choose karna jo bugs reveal karne ke zyada chances rakhti hain. Yeh subjective technique hai — no
systematic rules.
• Ye values kisi bhi program mein bugs reveal kar sakti hain
• Boundary values (BVT se same) — <=, <, >=, > confusion ke liye
Null / Empty String ya collection inputs mein Empty string, null pointer
Leap year dates Date calculation programs mein Feb 29 — leap year handling
■ EXAM TIP: Special value testing ko boundary value testing ke saath combine karo — dono
complementary hain. BVT systematic hai, Special value testing intuitive hai.
■ EXAM QUESTION: Special Value Testing kya hai? Date function ke liye kaunse special values
use karoge?
■ ANSWER: Special value testing: Tester ke experience se specific values choose karna jo bugs
expose karein. Date function ke liye: Feb 29 (leap year), Dec 31 (year boundary), Feb 28 (non-leap
year last day), Jan 1, 12 noon vs midnight, timezone boundaries. Yeh values common date bugs
expose karti hain.
Jab ek unit ke multiple parameters hain aur unke combinations pe behavior depend karta hai, tab
Combinatorial Testing use karte hain.
Conditions / Actions R1 R2 R3 R4 R5 R6 R7 R8
Agar ek condition ka value kuch bhi ho aur action same ho, toh '-' (Don't Care) likh sakte hain:
Components:
Constraints:
One and Only One (O) O between Exactly one must be true
causes
• Studies show: 67-90% of all software bugs are caused by interaction of just 1 or 2 parameters
• Only a small % of bugs need 3+ parameter interaction to trigger
• Conclusion: If we cover all 2-parameter combinations, we catch most bugs!
Example — 3 Parameters:
Tools:
■ EXAM QUESTION: Pairwise testing kab use karte hain? All combinations se kaise different hai?
■ ANSWER: Pairwise testing jab parameters zyada hon (5+) aur all combinations impractical hon. All
combinations: product of all parameter values. Pairwise: cover all 2-parameter combinations only.
Research: 67-90% bugs 1-2 parameter interactions se — pairwise yahi cover karta hai. Typically
O(sqrt(all_combinations)) test cases kaafi hain.
Missing features pakdta hai Dead code, unreachable paths pakdta hai
EC, BVT, Pairwise, Decision Table Statement, Branch, Path, MC/DC, Mutation
■ DHYAN DO: DONO ZAROOR HAIN! Black Box se dead code nahi pakdega. White Box se specification
mein missing feature nahi pakdega. Dono complementary hain.
Fault-Based Mutation Testing, Error Seeding Specific types of bugs detect karna check karo
Example:
1: def calculate(x):
2: if x > 0:
3: y = 1 # Statement 3
4: else:
5: y = -1 # Statement 5
6: z = x + y # Statement 6
7: return z # Statement 7
Test Case 1: x = 5
• 100% statement coverage mil jaati hai lekin branches miss ho sakti hain
• Example: Boolean condition mein sirf TRUE case test ho, FALSE miss
• Bugs hidden in uncovered branches nahi pakdenge
Subsumption Relationship:
■ NOTE: Statement coverage karna ek 'weak' guarantee hai. Production code mein minimum branch/decision
coverage target karo.
■ EXAM QUESTION: Statement aur Branch coverage mein kya fark hai? Ek example do jahan
statement 100% ho lekin branch nahi.
■ ANSWER: Statement: har statement execute ho. Branch: har decision ka T aur F both execute ho.
Example: if(x>0): y=1; z=x+y; — x=5 se y=1 aur z=x+y execute hote hain — 100% statement coverage
(else nahi hai!). Lekin branch coverage incomplete — else ki koi default branch nahi hai... if else tha toh
FALSE branch miss. Statement 100% lekin branch less if only TRUE tested.
Basic Condition Har atomic condition T aur F Minimum 2 KUCH NAHI (decision se bhi weak!)
Coverage dono values le
Basic Cond + Decision Basic condition aur decision Min 2-4 Statement + Branch
(BCD) dono achieve ho
Path Coverage Saare linearly independent V(G) paths Sab ke upar — strongest
paths execute hon
■ DHYAN DO: TRAP QUESTION: Basic Condition Coverage does NOT subsume Decision Coverage!
Yeh exam mein baar baar poochha jaata hai. Basic condition coverage WEAKER hai decision coverage
se!
Decision: if (A AND B)
■ EXAM QUESTION: Basic Condition Coverage aur Decision Coverage mein kya fark hai? Kyun
basic condition decision ko subsume nahi karta?
■ ANSWER: Decision Coverage: whole expression T aur F both ho. Basic Condition: har individual
condition T aur F ho. Basic condition doesn't subsume decision: Counter-example: if(A AND B) with
TC1=(T,F) and TC2=(F,T) — basic condition satisfied (both A,B take T and F) but decision ALWAYS
FALSE in both cases — decision coverage not achieved. This is why basic condition is actually weaker
than decision coverage!
• Multiple Condition Coverage (MCC) = 2^n test cases → n=10 ke liye 1024! Impractical
• Basic Condition Coverage = Too weak — decision coverage guarantee nahi
• Kya ek aise criterion hai jo thorough bhi ho aur practical bhi?
Answer: MC/DC!
■ DHYAN DO: MC/DC ka FAA mandate exam mein zaroor poochha jaata hai! Aviation safety-critical
software ke liye mandatory hai (DO-178B standard).
■ EXAM TIP: Yaad karo: 'Only one condition changes, and the decision also flips.' Yeh demonstration
karta hai ki woh condition ACTUALLY matter karti hai.
■ Example 2: Decision = A OR B
n = 2 conditions → n+1 = 3 test cases
TC A B A OR B Purpose
TC2 T F T A independent: only A changed (F→T), decision flipped (F→T). TC1+TC2 = A's pair
✓
TC3 F T T B independent: only B changed (F→T), decision flipped (F→T). TC1+TC3 = B's pair
✓
■ NOTE: C ki independence: TC3(F,T,T)=T vs TC5(F,T,F)=F — only C changes. Toh 5th test case add karna
hoga ya existing TCs mein se C ka pair mile toh theek hai. Complete MC/DC sometimes n+1 se thoda zyada ho
sakta hai depending on expression.
Short circuit: agar ptr == NULL toh [Link] check hi nahi hota
(Warna NullPointerException aata!)
■ EXAM TIP: Short-circuit evaluation ke saath MC/DC: Sirf un cases mein condition test karo jab woh
actually evaluated hoti ho. Isse test cases reduce bhi ho sakte hain.
■ EXAM QUESTION: MC/DC kya hai? A AND (B OR C) ke liye MC/DC test cases design karo.
■ ANSWER: MC/DC: har condition independently decision affect kare. n+1 test cases for n conditions.
A AND (B OR C): n=3, need 4 test cases. TC1=(T,T,F)→T [base], TC2=(F,T,F)→F [A independent: only
A changes, decision changes], TC3=(T,F,F)→F [B independent: only B changes, decision changes],
TC4=(T,T,T)→T [C independent with TC3: only C changes T→F gives TC3, F→T gives TC4... verify:
TC4(T,T,T)=T vs hypothetical where only C changes to F: (T,T,F)=T — hmm, same. Need another pair
for C... (T,F,T)→T vs (T,F,F)→F — C changes, decision changes. So that's C's pair].
Sequence (a=1; b=2; Node1 → Node2 → Node3 (Linear No branching, straight arrow
c=3;) chain)
if-else (if(x>0) y=1; else Condition node → 2 paths → merge 2 outgoing edges: TRUE and FALSE
y=-1;) node
if (no else) (if(x>0) y=1;) Condition node → body → next OR FALSE path skips body
skip body directly
while loop (while(cond) Cond node → body → back edge to Back edge creates cycle
body;) cond OR exit edge
do-while (do body Body → cond node → back to body Body executes at least once
while(cond);) OR exit
for loop Init → cond check → body → Same as while after unrolling
update → back to cond
switch (n cases) n outgoing edges from switch node One edge per case
Analysis:
• Step 1: Baseline path identify karo — usually longest path ya most common path
• Step 2: V(G) count karo — usi se paths needed count pata chalega
• Step 3: Baseline pe ek-ek decision node flip karo → naya independent path
• Step 4: Jab V(G) paths identify ho jaayein, ruko
3 paths = V(G) = 3 ✓
Practical Note:
• Real programs mein infinite paths ho sakti hain (loop 0 times, 1 time, 2 times...)
• Isliye linearly independent paths use karte hain — manageable finite set
• Tools automatically paths aur test data generate kar sakte hain
■ EXAM QUESTION: Program mein 3 if, 2 while, 1 for statement hai. V(G) kya hoga? Min test
cases?
■ ANSWER: V(G) = Total decision nodes + 1 = (3 + 2 + 1) + 1 = 7. Minimum 7 linearly independent
paths hain, isliye minimum 7 test cases chahiye path coverage ke liye.
Core Concepts:
Def-Use (DU) Pair Variable ki ek def se ek use (x defined at line 3) → (x used at line 7)
tak ka connection
DU Path Def se use tak ka path jisme Koi intermediate re-assignment nahi
woh variable redefine na ho
(def-clear)
All-Uses Har variable ki har (def, use) pair ke liye Medium More tests
kam se kam ek def-clear path cover ho
Complete Example:
DU Pairs for x:
■ EXAM TIP: Dataflow testing WHITE BOX technique hai — code dekhna padta hai. Coverage-based
white box testing ki ek advanced form.
■ EXAM QUESTION: def, use, p-use, c-use kya hain? Example code ke liye DU pairs identify karo.
■ ANSWER: def = variable ko value assign karna. use = variable ki value read karna. c-use =
computational expression mein use (z = x+2). p-use = predicate/condition mein use (if x>0). Example:
a=5 (def a), b=a+3 (c-use a), if(a>0) (p-use a). DU pairs for a: (def:line1, c-use:line2), (def:line1,
p-use:line3).
Real-World Analogy:
3 T run karo P pe Saare test cases pass hone chahiye (agar fail ho toh design mein bug hai)
4 Mutation operators apply Small changes karke mutant programs P1, P2, ... Pn banao
karo
5 T run karo har mutant Pi pe Same test suite, different (mutant) program
6 Compare outputs P aur Pi ka output alag hai? → Mutant KILLED. Same? → Mutant ALIVE
7 Alive mutants handle karo Agar alive: new test cases add karo to kill it. Agar equivalent: manually identify
karke exclude karo
Relational Operator > ko >= ya < se change if(x > 0) if(x >= 0)
Data Type Change int ko float etc. int count = 0 float count = 0
Killed Mutant Test suite ka koi test case detect Test suite STRONG hai — Good! Count in numerator
karta hai (P aur Pi ka output alag yeh bug pakad sakta hai of mutation score
ata hai)
Live / Alive Mutant Koi test case detect nahi kar saka Test suite WEAK hai — yeh New test cases add karo
(P aur Pi same output) bug nahi pakda to kill it
Equivalent Mutant Mutant logically SAME hai original Program ki semantics Manually identify karo,
program ke — koi test kabhi kill nahi change nahi hui exclude from score
kar sakta
■ DHYAN DO: Equivalent mutants identify karna NP-hard problem hai! Manually karna padta hai. Isse hi
mutation testing expensive hoti hai.
Example:
PARIBHASHA — Coupling Effect Hypothesis: Ek complex bug = set of simple bugs ka coupling. Agar
test suite simple mutants kill kar le, complex/coupled bugs bhi detect ho jaate hain. Simple error detectors
complex error bhi pakad lete hain.
■ EXAM QUESTION: Mutation testing mein 'alive mutant' ka kya matlab hai? Kya karna chahiye?
Equivalent mutant kya hai?
■ ANSWER: Alive mutant = test suite ne injected bug detect nahi kiya — saare tests pass ho gaye
mutant pe bhi. Matlab test suite weak hai. Action: Naye test cases add karo specifically to expose the
difference between original and mutant. Equivalent mutant: logically original jaisa hi hai — koi test kabhi
kill nahi kar sakta (same semantics). Inhe manually identify karke mutation score ke denominator se
exclude karo.
Wrong Parameter Type Caller alag type bhejta hai, callee Caller sends int, callee expects float
alag expect karta hai
Wrong Parameter Count Arguments ka count match nahi Caller sends 3 args, callee expects 2
karta
Wrong Parameter Order Order galat hai Caller sends (name, age), callee expects (age,
name)
Shared Data Bug Global variable ek module update Module A global counter change karta hai, Module
karta hai, doosra stale data use B purana value use karta
karta hai
Timing Issue Async calls mein race condition Function A ka result ready hone se pehle Function
B use karta hai
Module Hierarchy:
[M1] ← Top level
/ \
[M2] [M3] ← Middle level
/ \ |
Bottom-Up Steps:
Step 1: Test M4 alone (write Driver_for_M4)
Step 2: Test M5 alone (write Driver_for_M5)
Step 3: Test M6 alone (write Driver_for_M6)
Step 4: Integrate M2+M4+M5 (write Driver_for_M2)
Step 5: Integrate M3+M6 (write Driver_for_M3)
Step 6: Integrate M1+M2+M3 (no driver needed now!)
Bottom-Up ka Analysis:
• Advantage: Parallel testing possible — alag teams alag bottom modules test kar sakti hain
simultaneously
• Advantage: Actual data flow test ho sakta hai — low-level functions realistic test hote hain
• Disadvantage: Drivers likhne ka overhead
• Disadvantage: Top-level design aur architecture late validated hota hai
• Disadvantage: System-level test cases pehle run nahi ho sakte
Top-Down ka Analysis:
Big Bang Nothing All at once Simple, quick setup Isolation impossible, expensive
debugging
Bottom-Up DRIVERS Lowest modules Parallel testing, realistic data flow Late top-level testing, driver overhead
Top-Down STUBS Highest module Early design validation, no drivers Late low-level testing, stub overhead
Sandwich Both D+S Both ends Combines all advantages Middle layer double-tested, complex
■ EXAM TIP: SHORTCUT YAAD KARO: Bottom-Up → DRIVERS (B ka D → B ke liye D). Top-Down →
STUBS (T ka ST → Top ke liye STubs). Exam mein yeh distinction critical hai!
■ EXAM QUESTION: Top-Down aur Bottom-Up integration mein kya fark hai? Kab kaunsa use
karein?
■ ANSWER: Bottom-Up: lowest modules pehle test, DRIVERS likhte hain, parallel testing possible, top
design late validated. Top-Down: highest module pehle, STUBS likhte hain, design early validated,
low-level late. Use Bottom-Up: jab low-level utilities critical hon (database layer). Use Top-Down: jab
architecture aur high-level flow important ho. Real-world: Sandwich (both) sabse practical.
V or V? VERIFICATION VALIDATION
Test Type Kya Test Karte Hain Kaise Karte Hain Metric
Load Testing Normal expected load pe Expected number of Response time, throughput under normal
behavior concurrent users simulate load
karo
Stress Testing SRS limits se BEYOND Normal se zyada users/data System ka breaking point, graceful
mein behavior do degradation
Volume Testing Large amount of data Max DB size, large file Performance with max data
handle karna processing
Usability Testing User friendliness, ease of Real users observe karo Task completion time, error rate,
use tasks perform karte hue satisfaction
Reliability Testing Kitna time bina fail ke Extended period MTBF (Mean Time Between Failures)
chalega continuously run karo
Security Testing Unauthorized access, Penetration testing, SQL Vulnerabilities found and patched
vulnerabilities injection, XSS
Portability Testing Different OS/platforms pe Windows, Mac, Linux, Pass/Fail on each platform
kaam karna different browsers test karo
Recovery Testing Crash ke baad recovery Forcefully crash karo, Recovery time, data loss
recovery time measure karo
Performance Response time under Load + stress combination Response time, CPU, memory usage
Testing conditions
■ DHYAN DO: DEFINITION YAAD KARO — Stress Testing: Input given BEYOND what SRS specifies.
Yeh definition exactly poochhi jaati hai exam mein. Load testing = WITHIN limits. Stress testing =
BEYOND limits.
■ EXAM QUESTION: Stress testing aur Load testing mein kya fark hai?
■ ANSWER: Load Testing: SRS mein specified normal/expected load pe system ka performance test
karna — e.g., 1000 concurrent users (as specified). Stress Testing: SRS limits se BEYOND input dena
— e.g., agar SRS mein 1000 users specified hain toh 5000 ya 10000 users dena, ya data volume 10x
karna. Stress testing system ka breaking point dhundhta hai. Load testing normal operation verify karta
hai.
PARIBHASHA — Error Seeding Formula: Manager S bugs seed karta hai. Testing ke baad s seeded
bugs detect hue, n original bugs detect hue. Estimate: N = (n x S) / s total original bugs.
N = (n x S) / s
• Assumption: Seeded aur original bugs ka detection rate SAME hona chahiye
• Agar seeded bugs too easy: overestimate hoga
• Agar seeded bugs too hard: underestimate hoga
• 50,000 line ka software hai. Ek bug fix kiya — sirf 10 lines change ki
• Un 10 lines mein ek variable ka value change hua
• Woh variable doosre 15 functions mein bhi use hoti hai
• Un 15 functions mein se 3 ab galat kaam karne lagein → Regression Bugs!
• Pehle kaam karte the, change ke baad toot gaye
■ NOTE: Regression testing unit, integration, aur system — TEENO levels pe applicable hai. Change ke baad
sab levels pe regression test karo.
Obsolete / Invalid Test Jo test cases wo feature test karte DISCARD — hata Feature ab exist nahi karta — test
Cases the jo delete ya completely change do invalid ho gayi
ho gayi
Redundant Test Cases Jo features test karti hain jo change SKIP — run mat Change se unaffected code — fail
se completely independent hain karo hone ka chance zero, time waste
Regression Test Cases Jo changed code ya usse MUST RUN — Yeh regression bugs detect
dependent code test karti hain zaroor chalao karenge
• Goal: Bugs jaldi detect karna → development team jaldi fix kar sake → faster delivery
• Priority factors: recently changed code, historical failure data, code coverage
• High priority: Saari tests jinke paths changed code ke through jaate hain
• Low priority: Tests jo completely independent code cover karti hain
■ EXAM TIP: CI/CD (Continuous Integration/Delivery) mein regression testing AUTOMATED hoti hai —
har commit pe automatically run hoti hai. Yeh modern software development mein standard practice
hai.
■ EXAM QUESTION: Regression testing kyun ki jaati hai? Test suite ko change ke baad kaise
classify karte hain?
■ ANSWER: Change ke baad variable propagation se unrelated functions break ho sakti hain
(regression bugs). Isliye previously passing tests rerun karte hain. Classification: (1) Obsolete —
feature deleted/changed, discard. (2) Redundant — completely independent of change, skip. (3)
Regression — dependent on change, MUST RUN. Then minimize (remove duplicates) and prioritize
(high-probability first).
Inheritance Base class mein tested method New context — new variables, methods affect behavior
derived class mein fail ho sakta hai
Polymorphism Ek method call → runtime pe Compile time pe nahi pata kaunsi method call hogi
different implementations
Encapsulation Private state directly accessible Internal state verify karna mushkil
nahi
Dynamic Binding Method resolution runtime pe hota Sab possible bindings test karne padte hain
hai
Abstract Classes Directly instantiate nahi ho sakti Concrete subclasses ke through test karo
Multiple Inheritance Diamond problem, ambiguity Extra test cases for conflict resolution
Generics/Templates Type parameters kaafi Sab type combinations test karna impractical
combinations create karte hain
■ DHYAN DO: Inherited method retesting = RULE, not exception! Yeh baar baar exam mein poochha
jaata hai. 'Retesting is the rule rather than the exception.'
class A:
x = 100 # class variable initialized to 100
def m(self):
# m() REQUIRES x >= 100 to work correctly
return x + 50 # works fine when x = 100
# Testing in class A:
# A.m() → x=100, returns 150 ✓ [PASSES]
def m2(self):
return 5 # returns 5
# Testing in A:
# a = A(); a.m() → calls A.m2() → 5+10 = 15 ✓
# Testing in B:
# b = B(); b.m() → calls B.m2() (dynamic binding!)
# → -100 + 10 = -90 (VERY DIFFERENT!)
• New class variables in derived class → can violate invariants assumed by inherited methods
• New methods in derived class → can modify state that inherited methods depend on
• Dynamic binding → inherited method may call overridden version (different behavior)
• New class hierarchy → Weyukar's axiom: correctness at upper level doesn't guarantee lower level
Intraclass Testing Methods of ONE class, their Unit Testing in Single class, all its methods
interactions, valid/invalid method procedural
call sequences
Interclass Testing Multiple classes interacting, Integration Testing in Multiple related classes
cross-class method calls, procedural
inheritance chains
VALID sequences:
push(1) → push(2) → pop() → peek() ✓
push(1) → isEmpty() ✓
• Test both: valid sequences (correct behavior) + invalid sequences (proper error handling)
• State-based testing: Model object states as state machine → test transitions
■ EXAM QUESTION: Inheritance testing mein retesting kyun zaroori hai? Weyukar's Axiom kya
hai?
■ ANSWER: Weyukar's Anticomposition Axiom: base class mein sahi kaam karna derived class mein
guarantee nahi. Reasons: (1) new variables violate invariants, (2) new methods change state, (3)
dynamic binding overridden method call karta hai. Example: Class A mein x=100 hai, method m()
x>=100 assume karta hai. Class B mein m1() x=1 set karta hai. B mein m1() ke baad m() fail karta hai
— A mein kabhi nahi hua. Isliye RETEST RULE HAI.
6. Error Seeding: N = (n x S) / s
Basic Condition Coverage Min 2 ■ NOTHING — weaker than Individual atomic conditions T+F
Decision!
■ DHYAN DO: EXAM TRAP: 'Basic Condition Coverage subsumes Decision Coverage' — YEH GALAT
HAI! Basic Condition is WEAKER than Decision Coverage. Never say basic condition subsumes
decision.
Verification 'Building it right?' Code ko previous artifact (design) ke against check karna.
Validation 'Building right thing?' Final product ko SRS requirements ke against check karna.
Driver Test unit ko CALL karne wala simulator software. Caller substitute.
Cyclomatic Complexity V(G) Min linearly independent paths = min test cases for path coverage. V(G) = E-N+2.
MC/DC Each condition independently affects decision. n+1 test cases. FAA aviation
mandate.
Equivalent Mutant Logically identical to original — no test can kill it. Manually identify.
Pesticide Effect Same technique repeated use → surviving bugs become resistant/immune.
Regression Bug Previously working feature that breaks after a software change.
Error Seeding Inject known bugs → detection ratio → estimate remaining original bugs.
Pairwise Testing Cover all 2-parameter combinations. Catches 67-90% bugs with O(sqrt) test cases.
Weyukar's Axiom Base class method correctness does NOT guarantee derived class correctness.
Big Bang Integration All modules integrated at once. Simple but bug isolation impossible.
Bottom-Up Integration Lowest modules first. Needs DRIVERS. Parallel testing possible.
Top-Down Integration Highest module first. Needs STUBS. Early design validation.
Competent Programmer Hypothesis Programmers write almost correct programs — only minor errors.
Coupling Effect Complex bugs = set of simple bugs. Kill simple mutants = kill complex bugs too.
■ EXAM QUESTION: Q1. Error, Fault aur Failure mein kya fark hai? Example ke saath explain karo.
■ EXAM QUESTION: Q2. Pesticide Effect kya hai? Calculate: 800 bugs, 5 techniques, har ek 60%
effective.
■ ANSWER: Same technique baar baar use karne se bugs resistant ho jaate hain. Capers Jones:
~30% bugs detected per technique. Calculation: 800 x (0.4)^5 = 800 x 0.01024 = 8.2 ≈ 8 bugs survive.
■ EXAM QUESTION: Q3. Verification aur Validation mein difference kya hai?
■ ANSWER: Verification: 'Building it right?' code vs design. Developer karta hai. Static+Dynamic.
Unit/Integration testing. Validation: 'Building right thing?' product vs SRS. Tester karta hai. Only
Dynamic. System testing.
■ EXAM QUESTION: Q4. Draw CFG aur calculate V(G) for: if(x>0) { y=1; while(y<5) y++; } else y=-1;
■ ANSWER: Nodes: [if], [y=1], [while y<5], [y++], [y=-1], [end] = 6 nodes. Edges = 7. Decision nodes: if
+ while = 2. V(G) = 2+1 = 3. Or E-N+2 = 7-6+2 = 3.
■ EXAM QUESTION: Q5. MC/DC testing explain karo. Decision = A AND B ke liye test cases design
karo.
■ ANSWER: MC/DC: 4 requirements — entry/exit, condition coverage, decision coverage,
independence (each condition independently affects decision). n+1 test cases. A AND B: TC1=(T,T)=T,
TC2=(F,T)=F [A independent: TC1 vs TC2], TC3=(T,F)=F [B independent: TC1 vs TC3]. 3 test cases for
n=2.
■ EXAM QUESTION: Q6. Equivalence Class Partitioning explain karo. Age (18-65) ke liye ECs
design karo.
■ ANSWER: ECP: Input domain ko groups mein divide karo jahan sab values same behave karein. Ek
class se ek test value. Age (18-65): Valid EC={18-65, test=40}. Invalid EC1={<18, test=10}. Invalid
EC2={>65, test=70}. Weak EC: 3 test cases.
■ EXAM QUESTION: Q7. Boundary Value Testing explain karo. Salary range [10000, 100000] ke
values batao.
■ ANSWER: BVT: Programmers boundaries pe mistakes karte hain (off-by-one, < vs <=). 7 values:
9999 (invalid), 10000 (lower boundary), 10001 (just above), 55000 (nominal), 99999 (just below upper),
100000 (upper boundary), 100001 (invalid).
■ EXAM QUESTION: Q8. Bottom-Up aur Top-Down integration testing compare karo. Drivers aur
Stubs kya hain?
■ ANSWER: Bottom-Up: lowest modules first, DRIVERS likhte hain (caller simulate). Top-Down:
highest module first, STUBS likhte hain (called function simulate). Driver = test unit ko call karne wala.
Stub = test unit ke called function ka simulator. Bottom-Up: early low-level testing. Top-Down: early
design validation.
■ EXAM QUESTION: Q9. Mutation testing explain karo. Competent Programmer Hypothesis kya
hai?
■ EXAM QUESTION: Q10. Regression testing kyun ki jaati hai? Test suite classify karo.
■ ANSWER: Change ke baad variable propagation se unrelated features break ho sakti hain. Pehle
kaam karne wala code toot jaata hai. Classification: Obsolete (discard), Redundant (skip), Regression
(must run). Then minimize and prioritize.
■ EXAM QUESTION: Q11. Inherited methods ko derived class mein retest kyun karna padta hai?
■ ANSWER: Weyukar's Anticomposition Axiom: base class correctness derived class correctness
guarantee nahi karta. Reasons: new variables violate invariants, new methods change state, dynamic
binding overrides. Example: Class A mein x=100, m() works. Class B mein m1() sets x=1, then m() fails.
■ EXAM QUESTION: Q12. Pairwise testing kab use karte hain? 3 parameters, 2 values each ke liye
test set banao.
■ ANSWER: Jab parameters zyada hon aur all combinations impractical hon. Research: 67-90% bugs
2 params se. P1={A,B}, P2={C,D}, P3={E,F}: Pairs needed: P1-P2: AC,AD,BC,BD; P1-P3:
AE,AF,BE,BF; P2-P3: CE,CF,DE,DF. Test set: (A,C,E), (A,D,F), (B,C,F), (B,D,E) = 4 test cases cover
all pairs!
■ EXAM QUESTION: Q13. Error seeding formula explain karo. 300 seeded, 240 detected. 120
original found. N=?
■ ANSWER: Formula: N = (n x S) / s. n=120, S=300, s=240. N = (120 x 300) / 240 = 150. Total
estimated original bugs = 150. Still remaining = 150 - 120 = 30 bugs.
■ EXAM QUESTION: Q14. Basic Condition Coverage kyun Decision Coverage ko subsume nahi
karta?
■ ANSWER: Counterexample: if(A AND B). TC1=(T,F), TC2=(F,T). Basic Condition: A=T+F ✓, B=T+F
✓. Decision: BOTH cases = False! True branch NEVER executed ✗. So decision coverage NOT
achieved even though basic condition is. Basic condition is actually WEAKER than decision coverage.
■ EXAM QUESTION: Q15. Stress testing kya hai? Load testing se kaise alag hai?
■ ANSWER: Load testing: SRS mein specified NORMAL expected load pe performance verify karna.
Stress testing: SRS limits se BEYOND input dena — system ka breaking point find karna. Example:
SRS says 1000 users → Load: test with 1000. Stress: test with 5000, 10000 users to find breaking
point.
■ EXAM QUESTION: Q16. Decision table testing explain karo. 2 boolean conditions ke liye table
banao.
■ ANSWER: Decision table: conditions aur actions tabular form mein. n boolean conditions = 2^n rules.
Example: C1=User valid, C2=Password correct. R1=(T,T)→Login success. R2=(T,F)→Wrong
password error. R3=(F,T)→User not found. R4=(F,F)→User not found. Har rule ek test case.
■ EXAM QUESTION: Q17. Dataflow testing explain karo. def, p-use, c-use ke examples do.
■ EXAM QUESTION: Q18. White Box testing kyun zaroor hai agar Black Box testing ho rahi hai?
■ ANSWER: Black Box alone ki problem: Code mein kuch extra/unreachable code ho sakta hai jo
specification mein nahi tha. Black box se woh kabhi execute nahi hoga — detect nahi hoga. White Box
se code coverage ensure hoti hai — dead code, unreachable paths, logic errors pakde jaate hain. Dono
complementary hain.
■ EXAM QUESTION: Q19. V(G) = 5 ka kya matlab hai? Program ka code kya hoga approximately?
■ ANSWER: V(G) = 5 matlab 5 linearly independent paths hain, minimum 5 test cases chahiye path
coverage ke liye. Moderate complexity. Code mein approximately 4 decision nodes (if/while/for) =
V(G)=5. Program with 3 if statements + 1 while loop would give V(G) = 4+1 = 5.
■ EXAM QUESTION: Q20. Unit testing verification hai ya validation? System testing?
■ ANSWER: Unit testing = VERIFICATION. Code ko Detailed Design ke against check karna — 'are
we building it right?' Developer karta hai. System testing = VALIDATION. Complete product ko SRS ke
against check karna — 'are we building the right thing?' Tester karta hai. Verification = process
conformance. Validation = requirements conformance.
All the best for your IIT exam! Mehnat ka phal zaroor milega. ■
Prof. Rajib Mall — IIT Kharagpur — Software Testing (20 Lectures)