mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-20 17:47:57 +01:00
Handle junit's AssertionError in integration tests
This commit is contained in:
parent
a85ba5311e
commit
b9782aa6bc
2 changed files with 12 additions and 5 deletions
|
@ -21,9 +21,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class FailedTest extends TestResult {
|
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);
|
super(testMethod, startTime, endTime, logMessages);
|
||||||
this.failureReason = failureReason;
|
this.failureReason = failureReason;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class SmackIntegrationTestFramework {
|
||||||
final Method method = failedTest.testMethod;
|
final Method method = failedTest.testMethod;
|
||||||
final String className = method.getDeclaringClass().getName();
|
final String className = method.getDeclaringClass().getName();
|
||||||
final String methodName = method.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);
|
LOGGER.severe(className + CLASS_METHOD_SEP + methodName + " failed: " + cause);
|
||||||
}
|
}
|
||||||
System.exit(2);
|
System.exit(2);
|
||||||
|
@ -380,10 +380,17 @@ public class SmackIntegrationTestFramework {
|
||||||
null, (TestNotPossibleException) cause));
|
null, (TestNotPossibleException) cause));
|
||||||
continue;
|
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
|
// An integration test failed
|
||||||
testRunResult.failedIntegrationTests.add(new FailedTest(testMethod, testStart, testEnd, null,
|
testRunResult.failedIntegrationTests.add(new FailedTest(testMethod, testStart, testEnd, null,
|
||||||
nonFatalException));
|
nonFatalFailureReason));
|
||||||
LOGGER.log(Level.SEVERE, testPrefix + "Failed", e);
|
LOGGER.log(Level.SEVERE, testPrefix + "Failed", e);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException | IllegalAccessException e) {
|
catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
|
|
Loading…
Reference in a new issue