Testing code li juża database huwa challenging — għandek bżonn realistic data behavior mingħajr flakiness jew slowness. Approċċi jinkludu test databases, in-memory databases, transactions/rollback, u mocking the data layer — kull wieħed għandu trade-offs.
Il-isfida
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.
