try { shouldThrow(); } catch (SpecialException e) { return; } fail("Expected SpecialException");
new ExceptionTestCase("testShouldThrow", SpecialException.class);
34353637383940414243
public ExceptionTestCaseTest(String name) { super (name); } public void testExceptionSubclass() { ExceptionTestCase test= new ThrowExceptionTestCase("test", IndexOutOfBoundsException.class); TestResult result= test.run(); assertEquals(1, result.runCount()); assertTrue(result.wasSuccessful()); }
40414243444546474849
TestResult result= test.run(); assertEquals(1, result.runCount()); assertTrue(result.wasSuccessful()); } public void testExceptionTest() { ExceptionTestCase test= new ThrowExceptionTestCase("test", IndexOutOfBoundsException.class); TestResult result= test.run(); assertEquals(1, result.runCount()); assertTrue(result.wasSuccessful()); }
46474849505152535455
TestResult result= test.run(); assertEquals(1, result.runCount()); assertTrue(result.wasSuccessful()); } public void testFailure() { ExceptionTestCase test= new ThrowRuntimeExceptionTestCase("test", IndexOutOfBoundsException.class); TestResult result= test.run(); assertEquals(1, result.runCount()); assertEquals(1, result.errorCount()); }
52535455565758596061
TestResult result= test.run(); assertEquals(1, result.runCount()); assertEquals(1, result.errorCount()); } public void testNoException() { ExceptionTestCase test= new ThrowNoExceptionTestCase("test", Exception.class); TestResult result= test.run(); assertEquals(1, result.runCount()); assertEquals(1, result.failureCount()); }
58596061626364656667
TestResult result= test.run(); assertEquals(1, result.runCount()); assertEquals(1, result.failureCount()); } public void testWrongException() { ExceptionTestCase test= new ThrowRuntimeExceptionTestCase("test", IndexOutOfBoundsException.class); TestResult result= test.run(); assertEquals(1, result.runCount()); assertEquals(1, result.errorCount()); }