Testing Exceptions

An exception provides an alternative route for returning from a method that does not necessarily move to the next statement after the method is invoked. Exceptions are powerful in two respects:

  • The exceptional return value is an object and can be arbitrarily complex.

  • The points at which an exception is thrown varies based on the depth of the aggregation hierarchy.

Most interface designers use exceptions to handle error conditions that can arise during processing. Exceptions provide an alternative to return codes and in some situations can reduce the amount of code needed to process return codes. However, exceptions are also useful for processing exceptional conditions that arise during processing that are not really associated ...

Get A Practical Guide to Testing Object-Oriented Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.