FileDocCategorySizeDatePackage
ExceptionTestCase.javaAPI DocAndroid 1.5 API1023Wed May 06 22:41:02 BST 2009junit.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);

Fields Summary
Class
fExpected
Constructors Summary
public ExceptionTestCase(String name, Class exception)

		super(name);
		fExpected= exception;
	
Methods Summary
protected voidrunTest()
Execute the test method expecting that an Exception of class fExpected or one of its subclasses will be thrown

		try {
			super.runTest();
		}
		catch (Exception e) {
			if (fExpected.isAssignableFrom(e.getClass()))
				return;
			else
				throw e;
		}
		fail("Expected exception " + fExpected);