I have just been taught the lesson that when testing your code, test for failures too.
Take a method that removes a record from the database. You pass in the Id of the record and it DELETEs it. Initially I tested for an invalid Id (e.g. -1) and for a successful delete. I never tested to see what happens when you pass in a valid Id but an Id that doesn’t occur in the database. In this case the code ran as if it were successful. Really it should throw an exception as that Id does not exist in the database.
Test both ways!
Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)