O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Verify the Exception Instance

Each of the exception-based techniques so far essentially tried to infer the identity of the exception that we think should have been thrown by inspecting its characteristics: type, message, cause, and extended attributes. We have used increasing levels of detail to increase our confidence that we have identified the exception properly. You may have asked yourself, “Why not just inject the exception itself? Why not just use identity to verify identity?” That is the question this section addresses.

It almost goes without saying that identity is the strongest way to verify identity. But with objects—and particularly with exceptions—mutability and context are important.

Mutability refers to an object’s ability to be ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required