Skip to content
master
Go to file
Code
This branch is 19 commits ahead of thekua:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

README.md

logback-spike

Build Status JitPack License

Logback and SLF4j unit testing.

Original idea from thekua's blog, forked from his repo in order to provide it conveniently with good reuse as maven dependency.

Usage

Get it via JitPack, for example using maven.

Add the following maven repository to your POM.xml

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Then add the actual dependency

<dependency>
    <groupId>com.github.schnatterer</groupId>
    <artifactId>logback-spike</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

From here it's really simple to use:

// Given
LogbackCapturingAppender capturing = LogbackCapturingAppender.weaveInto(OurDomainWithLogger.LOG);

// when
new OurDomainWithLogger().logInfo("This should be logged{}", "!");

// then
assertThat(capturing.getCapturedLogMessages().get(0), is("This should be logged!"));

See LogbackCapturingAppender's javadoc and its unit test for more insights.