nCatch exception, and use fail(
) if not thrown
n
npublic void testException()
n{
n try
n {
n exceptionCausingMethod();
n
n //
If this point is reached, the expected
n //
exception was not thrown.
n fail("Exception
should have occurred");
n }
n catch (
ExceptedTypeOfException exc )
n {
n String expected
= "A suitable error message";
n String actual =
exc.getMessage();
n
Assert.assertEquals( expected, actual );
n }
n}