swetha wrote:
>> I changed my insertValues(int ID) method to throw the SQLException and
>> hence in my test method I had to surround the call to the method in a
>> try - catch block
Just to be clear - it's the catch block that is eating your exception, so that
the test cannot catch it.
> The test cannot catch the exception if you don't throw it.
>
> Review your JUnit documentation.
If you catch it, the test will not.
"expected=Exception" means that the Exception is expected, then you don't
deliver one! How can you tell the test "expected=Exception", then wonder why
it fails when you don't give it the expected Exception?

Signature
Lew
swetha - 24 Oct 2007 08:27 GMT
> "expected=Exception" means that the Exception is expected, then you don't
> deliver one! How can you tell the test "expected=Exception", then wonder why
> it fails when you don't give it the expected Exception?
I think I understand now : All Exceptions that are caught in the
actual method cannot be expected in the test method and hence given
that my method insertValues(int ID) was catching all Exceptions, I
should not have been expecting any exceptions.
Thanks for your patience. Sorry if I was slow to understand.