Handle junit's AssertionError in integration tests

This commit is contained in:
Florian Schmaus 2015-06-09 17:24:17 +02:00
parent a85ba5311e
commit b9782aa6bc
2 changed files with 12 additions and 5 deletions

View File

@ -21,9 +21,9 @@ import java.util.List;
public class FailedTest extends TestResult {
public final Exception failureReason;
public final Throwable failureReason;
public FailedTest(Method testMethod, long startTime, long endTime, List<String> logMessages, Exception failureReason) {
public FailedTest(Method testMethod, long startTime, long endTime, List<String> logMessages, Throwable failureReason) {
super(testMethod, startTime, endTime, logMessages);
this.failureReason = failureReason;
}

View File

@ -102,7 +102,7 @@ public class SmackIntegrationTestFramework {
final Method method = failedTest.testMethod;
final String className = method.getDeclaringClass().getName();
final String methodName = method.getName();
final Exception cause = failedTest.failureReason;
final Throwable cause = failedTest.failureReason;
LOGGER.severe(className + CLASS_METHOD_SEP + methodName + " failed: " + cause);
}
System.exit(2);
@ -380,10 +380,17 @@ public class SmackIntegrationTestFramework {
null, (TestNotPossibleException) cause));
continue;
}
Exception nonFatalException = throwFatalException(cause);
Throwable nonFatalFailureReason;
// junit assert's throw an AssertionError if they fail, those should not be
// thrown up, as it would be done by throwFatalException()
if (cause instanceof AssertionError) {
nonFatalFailureReason = cause;
} else {
nonFatalFailureReason = throwFatalException(cause);
}
// An integration test failed
testRunResult.failedIntegrationTests.add(new FailedTest(testMethod, testStart, testEnd, null,
nonFatalException));
nonFatalFailureReason));
LOGGER.log(Level.SEVERE, testPrefix + "Failed", e);
}
catch (IllegalArgumentException | IllegalAccessException e) {