Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should referential integrity from the database be unit tested?

Lets assume I have a Customer and Order table.

When I do a Customer_Delete_Test do you also Assert if the related Orders are deleted too or

do you rely on the referential integrity between the tables like On Cascade Delete ?

like image 706
Pascal Avatar asked Apr 21 '26 02:04

Pascal


1 Answers

I would unit test to ensure that you have constructed your database correctly and is behaving as you are expecting it to behave.

The database vendors may have done their job but that is only part of the story. Have you done yours correctly?

like image 143
Ed Heal Avatar answered Apr 24 '26 13:04

Ed Heal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!