Logback unit testing
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 19 commits ahead of thekua:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
README.md
pom.xml

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.