public class LogCaptureRule extends Object implements org.junit.rules.TestRule
Usage:
public @Rule LogCaptureRule logCaptureRule = new LogCaptureRule();
@Test ...
logRule.expectError();
See also e.g. slf4j-test or slf4jtesting (both of which, contrary to this, don't integrate with slf4j-simple which we already widely use in ODL tests).
ExpectedException| Constructor and Description |
|---|
LogCaptureRule() |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement statement,
org.junit.runner.Description description) |
void |
expectError(String message) |
void |
expectError(String message,
int howManyMessagesBack) |
void |
expectLastErrorMessageContains(String partialErrorMessage) |
Throwable |
getErrorThrowable(int howManyMessagesBack) |
Throwable |
getLastErrorThrowable() |
void |
handleErrorLogs(Consumer<com.google.common.collect.ImmutableList<LogCapture>> newErrorLogHandler) |
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement statement,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRulepublic void handleErrorLogs(Consumer<com.google.common.collect.ImmutableList<LogCapture>> newErrorLogHandler)
public void expectLastErrorMessageContains(String partialErrorMessage)
public void expectError(String message, int howManyMessagesBack)
public void expectError(String message)
public Throwable getLastErrorThrowable()
public Throwable getErrorThrowable(int howManyMessagesBack)
Copyright © 2020 OpenDaylight. All rights reserved.