CodeIgniter Forums
Unit testing - fix bugs which I think are imposible to happen in reality? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Unit testing - fix bugs which I think are imposible to happen in reality? (/showthread.php?tid=51888)



Unit testing - fix bugs which I think are imposible to happen in reality? - El Forum - 05-22-2012

[eluser]SPeed_FANat1c[/eluser]
hello,

lets say I have function which inserts row. But one of the fields is lets say clients_id. I cannot insert that row if clients_id is not in another table (foreign key does not exist), then database throws error.

So my unit test will get errors with wrong client id.

But actually I see in my application that it is imposible situation because, cliens_id is taken from session, and if session is gone, then page will be redirected to login page, so no insert will be made anyway.

So now the question - what in your opinion is best practice - to fix still that error, or not even test that insert function if I see its imposible that wrong client_id is passed?