Skip to content

Repository files navigation

assertlog

Unit-tests for your logging

Maven CentralMIT LicenseFreeBuild Status

What is AssertLog?

AssertLog is a library for unit-testing logging in your application.

Sometimes logging is very important, especially if it contains sensitive information, security incidents, money transfers etc.

Here is how you can use AssertLog:

importorg.assertlog.junit4.log4j.MockLogging;
importorg.junit.Rule;
importorg.junit.Test;
publicclassPetClinicTest {
@RulepublicMockLoggingmockLogging = newMockLogging();
@Testpublicvoidpayment() {
// make a paymentmockLogging.assertLogged("INFO", "Buying 2 Cows for 99.66 eur");
}
@AfterpublicvoidtearDown() {
mockLogging.assertNoMoreLogs();
}
}

What logging frameworks are supported?

We plan to support all major Java logging frameworks. Currently only Log4j 1 and JUnit 4 are supported.

Dependency

You need to add this dependency to you pom.xml:

<dependency>
<groupId>com.codeborne.assertlog</groupId>
<artifactId>assertlog-log4j-junit4</artifactId>
<version>0.1</version>
<scope>test</scope>
</dependency>

or build.gradle:

testImplementation('com.codeborne.assertlog:assertlog-log4j-junit4:0.1')

License

AssertLog is open-source project, and distributed under the MIT license.

About

Unit-tests for your logging

Resources

Stars

3 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages