verify()
Purpose
Checks that an exception is thrown.
Syntax
verify( <exception> )
where:
<exception> is a throwable exception
Description
Verifies that an exception compatible with the specified <exception> is thrown during the test.
The corresponding test result is Passed if the exception in thrown or Failed if not.
If an exception is thrown in a verify() method, an error is logged and the test continues.
Examples
public void WillThrowRTE()
{
verifyLogMessage("RTE in next call");
throw new RuntimeException("Exception Message");
}
public void testException1()
{
verifyLogMessage("Check true for RTE");
Throwable tosee= new RuntimeException("Exception Runtime ");
verify(tosee);
WillThrowRTE();
}
public void testException2()
{
verifyLogMessage("Check true for RTE");
Throwable tosee= new Exception("Exception");
verify(tosee);
WillThrowRTE();
}
public void testException3()
{
verifyLogMessage("Check true for RTE");
Throwable tosee= new Throwable();
verify(tosee);
WillThrowRTE();
}
public void testException4()
{
verifyLogMessage("Check false for RTE");
Throwable tosee= new ArithmeticException("Throwable");
verify(tosee);
WillThrowRTE();
}
public void testException5()
{
verifyLogMessage("Check false for RTE");
Throwable tosee= new ClassCastException("Throwable");
verify(tosee);
WillThrowRTE();
}
public void testException6()
{
verifyLogMessage("Check false for RTE");
Throwable tosee= new ClassCastException("Throwable");
verify(tosee);
//Do not call anything.
}