Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Add logback example to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
steveorourke committed Dec 7, 2018
1 parent 4ad2d7a commit b3be603
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<dependency>
<groupId>com.tyro.oss</groupId>
<artifactId>log-testing</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
```

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
Expand Down

0 comments on commit b3be603

Please sign in to comment.