diff --git a/README.md b/README.md index 902c3fd..1e0711c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,46 @@ # log-testing +[![Download](https://maven-badges.herokuapp.com/maven-central/com.tyro.oss/log-testing/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.tyro.oss/log-testing) + A simple library for testing log events. +## Getting Started + +log-testing is available on Maven Central. +```xml + + com.tyro.oss + log-testing + 2.1 + test + +``` + +A typical test using Logback and JUnit 5 looks like the following. Log4j and JUnit 4 are also supported. +```kotlin +import com.tyro.oss.logtesting.logback.LogbackAssert.Companion.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.RegisterExtension +import org.slf4j.LoggerFactory + +class ExampleTest { + + private val logger = LoggerFactory.getLogger(ExampleTest::class.java) + + @RegisterExtension + val log = LogbackCaptor(ExampleTest::class) + + @Test + fun `should log message`() { + logger.info("test message") + + assertThat(log) + .hasSize(1) + .hasInfo("test message") + } +} +``` + ## Copyright and Licensing Copyright (C) 2018 Tyro Payments Pty Ltd