PAU OJ Online Judge
ProblemsLearnStudy plansContestsSubmissionsRank

Updates

Announcements and upcoming contests

Loading announcements…
Sign in for personal alertsBrowse contests
Log inSign up

PAU OJ

PrimeAsia University Online Judge

A real online judge for programming practice, university contests and coding assessments. Write code in your browser, get sandboxed verdicts, and track your progress.

Platform

  • Problems
  • Contests
  • Submissions
  • Ranking
  • Reviewers

Resources

  • User guide
  • Changelog
  • How judging works
  • System health
  • Create an account

© 2026 PrimeAsia University Online Judge. All rights reserved.

v0.9.0

  1. All tracks
  2. Master class
  3. Testing

Testing

টেস্টিং

Topic 36 of 41Story · visual · design practice

In this lesson

  • Story & concept
    • কেন দরকার
    • মূল ধারণা
    • কোডে দেখি
    • ধাপে ধাপে
    • সাধারণ ভুল
      • ল্যাব: একটা bug ধরো
      • চিট শিট
      • প্রোডাকশন নোট
  • Visual story
  • Design practice
  • Checkpoint
  • Discussion
Back to track

0/0 solved

unit, integration, contract, E2E, load—risk-ভিত্তিক fast feedback।

In this lesson

  • Story & concept
  • Visual story
  • Design practice
  • Checkpoint
  • Discussion
01

Step 1: Story & concept

Start with the production incident, then the design decision that fixes it.

কেন দরকার

চলো-র payment service-এর unit test সব সবুজ। Friday deploy-এর পর দেখা গেল invoice total ভুল—কারণ currency conversion service-এর contract বদলেছে, কিন্তু payment service-এর mock পুরোনো response দিচ্ছিল। Unit test ঠিকই পাস করেছে; integration test ছিল না।

মাহিন বলল, "test pyramid ভেঙে পড়েছে—আমরা শুধু পিরামিডের তলা মজবুত করেছি, মাঝখানে কিছু নেই।" Testing মানে coverage number নয়; বোঝা যে change-এর পর সিস্টেম আগের মতোই কাজ করবে। unit দ্রুত, integration বাস্তব, contract দুই service-এর চুক্তি, E2E user journey, load capacity—প্রতিটা আলাদা প্রশ্নের উত্তর দেয়।

মূল ধারণা

Unit test। এক function/class, milliseconds, external dependency mock। Business logic, edge case, validation—এখানে। ৭০% test এখানে হওয়া উচিত, কিন্তু unit mock-কে সত্য ভেবো না।

Integration test। Real DB/Redis/queue, এক service-এর ভিতরের interaction। Migration, transaction, unique constraint, SQL—এখানে ধরা পড়ে। Container/test DB ব্যবহার করো।

Contract test। দুই service-এর request/response schema; producer/consumer একই contract test চালায়। Payment-service invoice বদলালে consumer test fail করবে—এটাই missing ছিল।

E2E। Browser/API দিয়ে user journey; ধীর, তাই কম। Booking → payment → confirmation—happy path + এক-দুই critical failure।

Load/soak test। Capacity, p95, memory leak; staging-এ realistic data। ১০k SSE-র মতো test আলাদা।

Test data আর flakiness। প্রতিটা test নিজের data বানায়/মুছে; shared fixture নয়। Flaky test quarantine, root cause; retry দিয়ে ঢেকে দিও না।

স্তরগতিকী ধরেকত
Unitmslogic, edgeবেশি
Integration১০০ms–sDB, queue, SQLমাঝারি
Contractms–sAPI schemaপ্রতি service
E2Es–minuser journeyকম
Loadmincapacityrelease gate

কোডে দেখি

একটা unit + integration test-এর পার্থক্য:

def test_total_with_tax():
    assert invoice_total([100, 200], tax=0.05) == 315.0

# integration: real DB unique constraint
def test_double_booking(db):
    db.insert_booking(ride_id="r1", seat_id="s1", rider_id="u1")
    with pytest.raises(UniqueViolation):
        db.insert_booking(ride_id="r1", seat_id="s1", rider_id="u2")
# load smoke: p95 under 300ms at 50 concurrent
k6 run --vus 50 --duration 60s load/booking.js
# contract: consumer verifies producer schema
pytest tests/contract/test_payment_consumer.py

Unit test DB constraint ধরে না; integration test ধরে। দুটোই দরকার—একটা আরেকটার বিকল্প নয়।

ধাপে ধাপে

১. Risk map করো। কোন module-এ bug হলে টাকা/PII/outage? সেখানে বেশি test, কম ঝুঁকিতে কম।

২. Pyramid ঠিক করো। Logic unit, DB/queue integration, service boundary contract, critical journey E2E, release load।

৩. CI-তে fast gate। Unit+contract ৫ মিনিটে; integration/container ১৫ মিনিট; E2E/load nightly বা release।

৪. Test data isolation। প্রতিটা test unique id, cleanup; shared user/DB state নয়। Migration test fresh DB-তে।

৫. Flaky management। Quarantine, owner, deadline; retry নয়। Coverage নয়, mutation/risk-ভিত্তিক test।

সাধারণ ভুল

  • শুধু unit test আর mock। Contract/DB/queue ভাঙলে unit সবুজ থেকেও production fail করবে।
  • Coverage number-কে quality ভাবা। ৯০% coverage-এ critical path বাদ থাকতে পারে।
  • Shared test data/fixture। Test order-এ dependency, flaky; প্রতিটা test নিজের data বানাক।
  • Flaky test retry দিয়ে লুকানো। Root cause (time/race) ঠিক করো, নইলে signal হারাবে।
  • Production-এ test করা। Staging/canary/feature flag দিয়ে risk কমানো।
  • Load test না করা। Release-এ p95/capacity না মাপলে traffic spike-এ outage।

ল্যাব: একটা bug ধরো

invoice_total-এ currency conversion যোগ করো। প্রথমে unit test লেখো, তারপর এমন integration test লেখো যেটা ভুল currency rate ধরে। শেষে contract test-এ response schema বদলে দেখো consumer fail করে কি না। কোন স্তর bug ধরল, লিখে রাখো।

চিট শিট

প্রোডাকশন নোট

Coverage ৯০% মানে ১০% ঝুঁকি নেই—numbers নয়, risk দেখো। Production-এ canary/feature flag দিয়ে test করো; test environment production নয়। Migration test fresh DB + existing data দুইটাতেই চালাও; শুধু fresh DB-তে পাস করলে production drift ধরবে না।

02

Step 2: Visual story

See the mental model first — the animation and the steps below it say the same thing.

Concept visual

দ্রুত ফিডব্যাকের সিঁড়ি

unit সেকেন্ডে চলে, e2e মিনিটে—নিচের ধাপ যত মোটা, উপরে তত কম পরীক্ষা থাকে।

unit✓ pass
integration✓ pass
contract✓ pass
e2e✓ pass
gateapprove
deployprod
jobs সিরিয়ালি চলেgate ছাড়া deploy নয়
  1. 1unit দিয়ে logic ঢাকোএক function, মিলিসেকেন্ডে
  2. 2integration-এ DB আর queueআসল Postgres-এ চালাও
  3. 3contract টেস্ট রাখোAPI বদলালে ক্লায়েন্ট ভাঙে না
  4. 4e2e অল্প রাখো৫–১০টা মূল flow, বাকিটা unit
  5. 5flaky test আলাদা করো১০% fail মানে সিগন্যাল নয়
5টি ধাপে দেখা হচ্ছেগতি কমালে স্থির
03

Step 3: Design practice

Write a short design on paper or in a note, then compare it with the rubric. This is not a judge submission.

Design practice

Green unit, broken prod

20 min

payment unit সব green; currency contract বদলে prod ভাঙল।

তোমার কাজ

  1. 1test pyramid/risk map করো।
  2. 2contract + integration test design করো।
  3. 3flaky/load gate plan লেখো।

ভালো উত্তরে কী থাকবে

  • layer/risk
  • contract/integration
  • flaky/load
04

Step 4: Checkpoint

One timed attempt. Solve every problem to earn the module badge.

Final checkpoint

Ready to prove this module?

45 minutes3 problemsScale Architect badge
Go to checkpoint
05

Step 5: Discussion

Ask questions, share an approach or leave a study tip for this lesson.

Was this lesson helpful?

Your reaction helps other learners judge these notes.

Sign in to react

Discussion

0 comments

Sign in to ask a question or share an approach.

Sign in to comment

No comments yet

Be the first to ask a question or leave a study tip.

Topic 36 of 41

PreviousEncryption & Secretsএনক্রিপশন ও সিক্রেটTopic 35 of 41
NextCI/CD & DeploymentsCI/CD ও ডিপ্লয়মেন্টTopic 37 of 41
Back to track: System Design MasterclassAll learning tracks
প্রশ্নউত্তর
Logic?unit
DB/SQL?integration
API change?contract
User journey?E2E
Capacity?load/soak
Flaky?quarantine + fix