junit.extensions
Class ExceptionTestCase
java.lang.Object
TestCase
junit.extensions.ExceptionTestCase
public class ExceptionTestCase
- extends TestCase
A TestCase that expects an Exception of class fExpected to be thrown.
The other way to check that an expected exception is thrown is:
try {
shouldThrow();
}
catch (SpecialException e) {
return;
}
fail("Expected SpecialException");
To use ExceptionTestCase, create a TestCase like:
new ExceptionTestCase("testShouldThrow", SpecialException.class);
ExceptionTestCase
public ExceptionTestCase(String name,
Class exception)