This past week proved me that the way I test my code is not good enough. The QA Engineer who tested my code logged many bugs on the negative test cases. I test mostly positive test cases and the negative test cases the user should see on some errors and the ones I think are *possible*. How do I decide that it is possible? Intuition. The code kept hitting different asserts and crashed because I did not handle those error conditions.
After looking at all the crashes I changed my way of testing a little bit. I first test the positive test cases, user perceivable error cases. Then either instrument the code or assign error values to the relevant variables in gdb so that the execution will hit the remaining negative test cases for the functions I modify.
This method already gave good result for my recent commit. I found a new bug lingering in the code. It is very difficult to hit that test case with normal testing, may be a good code reviewer could find it out.
If this model does not scale well, may be I should introduce Fault Injection Points into the code so that the bugs in -ve test cases are caught.
How do you go about testing -ve test cases in your code?.
No comments:
Post a Comment