29 / 65 · 15 SQL & Database Testing · Constraint Testing← prev⊞ allnext →☰ Read as one page
4.4Why Test Constraints?
"If the database has the constraint, why test it?" Because:
- Constraints can be accidentally removed during migrations
- Constraints may not exist even when you assume they do
- Application code may bypass constraints (e.g., ORM bug, raw SQL)
- Constraint behavior varies (CASCADE vs RESTRICT, case sensitivity)
- Documentation — constraint tests document the data integrity rules