ایسے کوڈ کی جانچ کرنا جو ڈیٹا بیس استعمال کرتے ہیں مشکل ہے — آپ کو حقیقی ڈیٹا کے رویے کی ضرورت ہے بغیر عدم استحکام یا سست رفتاری کے۔ اقدامات میں ٹیسٹ ڈیٹا بیسز، ان میموری ڈیٹا بیسز، ٹرانزیکشنز/رولبیک، اور ڈیٹا لیئر کو موک کرنا شامل ہیں — ہر ایک کے فوائل و نقصانات ہیں۔
چیلنج
Database-interacting code needs testing, but databases bring challenges:
→ real DB → realistic but SLOWER; needs SETUP and CLEANUP (state between tests)
→ shared state → tests can interfere (order dependence, flakiness)
→ mocking the DB → fast but may not catch real query/integration bugs
→ Choose an approach balancing realism, speed, and isolation.
