4.5.13 · HinglishSoftware Engineering

Testing — unit, integration, system, acceptance, smoke, regression

2,132 words10 min readRead in English

4.5.13 · Coding › Software Engineering


The Test Pyramid (testing ka 80/20)

Figure — Testing — unit, integration, system, acceptance, smoke, regression

Chhe types — WHAT / WHY / HOW


Worked examples


Do key "numbers" jo derive karne layak hain


Flashcards

Unit test kya isolate karta hai aur kaise?
Sabse chhoti piece (function/class) ko dependencies ko mocks/stubs se replace karke.
Integration test — yeh specifically kya check karta hai?
Ki do ya zyada units apne seam/interface par sahi tarike se saath kaam karte hain (often real collaborators jaise DB ke saath).
System test kaun sa V&V question answer karta hai?
Verification — "kya hum product sahi tarike se bana rahe hain?" (spec ko meet karta hai, full app black-box).
Acceptance test kaun sa V&V question answer karta hai?
Validation — "kya hum sahi product bana rahe hain?" (user/business need ko meet karta hai; UAT).
Smoke test ka purpose kya hai?
Ek chhota fast check ki build fundamentally broken nahin hai; poore suite ko gate karne ke liye pehle run karo.
Regression test ka purpose kya hai?
Change ke baad existing tests dobara run karna taaki ensure ho ki pehle kaam karne wale features abhi bhi kaam karte hain.
Test pyramid neeche wide kyun hoti hai?
Unit tests fast, cheap, deterministic hote hain aur faults pinpoint karte hain; high-level tests slow/flaky/vague hote hain — isliye bahut saare cheap wale likho.
Ek bug ke n stages escape karne ki cost (formula)?
, roughly har stage par 10×.
DB integration test mein database mock kyun nahin karna chahiye?
Aap mock test kar rahe hoge, real seam nahin — yeh unit test mein degenerate ho jaata hai.
n independent tests ke liye suite trust probability jisme har ek p reliable hai?
— flaky tests tezi se compound karte hain.

Recall Feynman: ek 12-saal-ke bacche ko samjhao

Socho tum ek LEGO spaceship bana rahe ho. Unit test: tum check karte ho ki har LEGO brick cracked nahin hai. Integration test: tum do bricks snap karte ho aur kheenchte ho — kya woh hold karti hain? System test: tum poori spaceship ko room mein udaate ho — kya yeh kaam karta hai? Acceptance test: tum apne dost ko dikhate ho jisne kaha tha "mujhe ek laal spaceship chahiye" — kya yeh actually unki mangi hui laal hai? Smoke test: kuch bhi karne se pehle, tum bas check karte ho ki yeh uthate hi bikhar nahin jaati. Regression test: nayi wing add karne ke baad, tum check karte ho ki purani wing pop off nahin hui. Har brick check karna sasta hai; crack tab dhundhna jab spaceship crash kar chuki ho yeh expensive hai — isliye hum pehle choti cheezein check karte hain aur aksar karte hain.


Connections

  • Test-Driven Development (TDD) — failing unit test pehle likho.
  • Mocks Stubs and Fakes — woh tools jo unit isolation possible banate hain.
  • Continuous Integration — jahan smoke + regression automatically har commit par run hote hain.
  • Verification and Validation — system vs acceptance ka V&V framing.
  • Code Coverage — measure karna ki aapke tests code ko kitna exercise karte hain.
  • Behaviour-Driven Development (BDD) — acceptance tests ke liye Given/When/Then.
  • Defect Cost of Delay — jaldi testing ke peeche ki economics.

Concept Map

many, cheap, fast

fewer

very few, slow

isolates via mocks/stubs

catches

combine units

assemble app

works correctly?

right thing? UAT/BDD

quick check before

triggers

re-runs

motivates catching early

Test Pyramid

Unit test

Integration test

System test

Faults at seams

Acceptance test

Customer requirements

Smoke test

New change

Regression test

Bug cost ~10x per stage