public class LogCaptureExtension extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
Usage:
@RegisterExtension and using a non private variable
@RegisterExtension
LogCaptureExtension logCapture = new LogCaptureExtension(LogLevel.INFO);
| Constructor and Description |
|---|
LogCaptureExtension()
Captures all logs from severity
LogLevel.INFO and higher (WARN, ERROR, etc). |
LogCaptureExtension(LogLevel level) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
void |
beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
ch.qos.logback.classic.spi.ILoggingEvent |
getLogEvent(int position) |
org.slf4j.Marker |
getMarker(int position) |
String |
getMessage(int position) |
void |
ignoreAllMessages()
Voluntarily ignore all messages to signify they should not need to be asserted.
|
void |
ignoreMessage(int position)
Voluntarily ignore a message to signify it should not need to be asserted.
|
int |
size() |
public LogCaptureExtension(LogLevel level)
level - the logging level from which to start capturing logs (for example if LogLevel.INFO then
INFO, WARN, ERROR, etc are captured too).public LogCaptureExtension()
LogLevel.INFO and higher (WARN, ERROR, etc).public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
throws Exception
beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallbackExceptionpublic void afterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext)
throws Exception
afterEach in interface org.junit.jupiter.api.extension.AfterEachCallbackExceptionpublic ch.qos.logback.classic.spi.ILoggingEvent getLogEvent(int position)
position - the message number in the list of captured logspublic String getMessage(int position)
position - the message number in the list of captured logspublic org.slf4j.Marker getMarker(int position)
position - the message number in the list of captured logspublic int size()
public void ignoreAllMessages()
public void ignoreMessage(int position)
position - the message number in the list of captured logsCopyright © 2004–2019 XWiki. All rights reserved.