concept exception in category software development

This is an excerpt from Manning's book Test Driven: Practical TDD and Acceptance TDD for Java Developers.
Another thing to think about in the fragmented market is the fact that two systems rarely have the exact same interfaces. The exception to the rule is web applications, which can all be accessed with standard technologies such as the HTTP protocol and the HTML markup language. What’s more important than the technologies involved, however, is how the tools aim to support our primary interest with acceptance TDD—close customer collaboration.
See the difference? The requirements have been transformed into something that’s clearly a degree more concrete, more executable, more example-like. With these tests as our completion criteria, there’s no question of whether we’re there yet or not. With these tests, we don’t need to wonder, for example, what it means to “raise an error” and, assuming it means throwing an exception, what kind of an exception it should be and what the exception message should say. The tests tell us that we should throw a MissingValueError exception and that we’re not interested in the specific error message.
How do we write a JUnit test that verifies that an exception is thrown? With the try-catch construct, of course, except that this time, the code throwing an exception is a good thing—the expected behavior. The approach shown in listing 2.14 is a common pattern[5] for testing exception-throwing behavior with JUnit.
Listing 2.14. Testing for an exception
@Test public void missingValueRaisesException() throws Exception { try { new Template("${foo}").evaluate(); fail("evaluate() should throw an exception if " + "a variable was left without a value!"); } catch (MissingValueException expected) { } }Note the call to the fail method right after evaluate. With that call to org.junit.Assert#fail, we’re basically saying, “if we got this far, something went wrong” and the fail method fails the test. If, however, the call to evaluate throws an exception, we either catch it and ignore it—if it’s of the expected type—or let it bubble up to JUnit, which will then mark the test as having had an error.
Testing for exceptions with an annotation