1 package junit.extensions; 2 3 import junit.framework.TestCase; 4 5 23 public class ExceptionTestCase extends TestCase { 24 Class fExpected; 25 26 public ExceptionTestCase(String name, Class exception) { 27 super(name); 28 fExpected= exception; 29 } 30 34 protected void runTest() throws Throwable { 35 try { 36 super.runTest(); 37 } 38 catch (Exception e) { 39 if (fExpected.isAssignableFrom(e.getClass())) 40 return; 41 else 42 throw e; 43 } 44 fail("Expected exception " + fExpected); 45 } 46 } | Popular Tags |