Editorials

Testing for Failure

Testing for failure is just as important as testing for success. Sometimes it is easy to forget to test for failure.

Often we perform validation for data entry forms. This is a great place to test for failure. There may be many permutations for which you must test. In order to have reasonable confidence you need to test for any input parameter that may cause you system to behave incorrectly.

Other times you may have a system failure of some sort, such as an appliance is busy and cannot respond to your request in the time allotted. In this case you receive some kind of exception. Do you test for your systems accurate handling of this kind of error.

Another error may be raised in your own software logic due to some custom condition you define. Here is another example of testing for failure; in short your test should confirm that when the defined condition occurs it raises an error.

So, your negative testing may be in the form of an integration test or a unit test. Custom errors are easy to test through unit tests. Missing resources may be tested in a unit test using a mock returning resource unavailable, or it may be done in an integration test by turning off the resource on which you depend, or injecting a delay somehow.

Regardless, don’t forget to also perform your negative testing for full coverage of your system.

Cheers,

Ben