1 package junit.extensions;
3 import junit.framework.*;
6 * A TestCase that expects an Exception of class fExpected to be thrown.
7 * The other way to check that an expected exception is thrown is:
12 * catch (SpecialException e) {
15 * fail("Expected SpecialException");
18 * To use ExceptionTestCase, create a TestCase like:
20 * new ExceptionTestCase("testShouldThrow", SpecialException.class);
23 public class ExceptionTestCase extends TestCase {
26 public ExceptionTestCase(String name, Class exception) {
31 * Execute the test method expecting that an Exception of
32 * class fExpected or one of its subclasses will be thrown
34 protected void runTest() throws Throwable {
39 if (fExpected.isAssignableFrom(e.getClass()))
44 fail("Expected exception " + fExpected);