testResult.setStatus(ITestResult.SUCCESS);
status= ITestResult.SUCCESS;
}
else {
testResult.setThrowable(
new TestException("The exception was thrown with the wrong message:" +
" expected \"" + expectedExceptionsHolder.messageRegExp + "\"" +
" but got \"" + ite.getMessage() + "\"", ite));
status= ITestResult.FAILURE;
}
} else if (SkipException.class.isAssignableFrom(ite.getClass())){
SkipException skipEx= (SkipException) ite;
if(skipEx.isSkip()) {
status = ITestResult.SKIP;
}
else {
handleException(ite, testMethod, testResult, failureCount++);
status = ITestResult.FAILURE;
}
} else if (ite != null && expectedExceptionsHolder != null) {
testResult.setThrowable(
new TestException("Expected exception "
+ expectedExceptionsHolder.expectedClasses[0].getName()
+ " but got " + ite, ite));
status= ITestResult.FAILURE;
} else {
handleException(ite, testMethod, testResult, failureCount++);
status= testResult.getStatus();
}
}
// No exception thrown, make sure we weren't expecting one
else if(status != ITestResult.SKIP && expectedExceptionsHolder != null) {
Class<?>[] classes = expectedExceptionsHolder.expectedClasses;
if (classes != null && classes.length > 0) {
testResult.setThrowable(
new TestException("Method " + testMethod + " should have thrown an exception of "
+ expectedExceptionsHolder.expectedClasses[0]));
status= ITestResult.FAILURE;
}
}