valfirst / slf4j-test

Implementation of SLF4J which allows easy access to logging events in tests
https://valfirst.github.io/slf4j-test/
MIT License
30 stars 10 forks source link
hacktoberfest logging slf4j testing

SLF4J Test

slf4j-test CI Coverage Status Quality Gate Codacy Badge Maven Central Javadocs Known Vulnerabilities MIT licensed FOSSA Status

A test implementation of SLF4J that stores log messages in memory and provides methods for retrieving them. This implementation supports all versions of SLF4J including 1.8.X which have a new binding mechanism.

Installation

The easiest way is to include it in your project(s) by ways of a Maven dependency. Binary, Sources and Javadocs are all available from Maven Central.

<dependency>
    <groupId>com.github.valfirst</groupId>
    <artifactId>slf4j-test</artifactId>
    <version>3.0.1</version>
</dependency>

Compatibility Matrix

org.slf4j:slf4j-api com.github.valfirst:slf4j-test
1.8.0-beta0 - 2.0.0-alpha2 1.3.0 - 2.3.0
2.0.0-alpha3 - 2.0.0-alpha5 2.4.0 - 2.4.1
2.0.0-alpha6 - 2.0.16 2.5.0 - 3.0.1

JUnit 5 Support

Declarative Extension Registration

SLF4J Test provides JUnit Platform extension which can registered via annotation:

import org.junit.jupiter.api.extension.ExtendWith;
import com.github.valfirst.slf4jtest.TestLoggerFactoryExtension;

@ExtendWith(TestLoggerFactoryExtension.class)
class BasicJUnit5Test {
   ...
}

Automatic Extension Registration

SLF4J Test supports automatic extension registration via ServiceLoader mechanism. This feature is considered advanced in JUnit Platform and it requires explicit enabling.

Documentation

See https://valfirst.github.io/slf4j-test/ for details.

Credits

This project is based on the original implementation by Robert Elliot, located at https://github.com/Mahoney/slf4j-test which worked with SLF4J prior to version 1.8.X.

License Scan

FOSSA Status