Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added your testcase as documentation described #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added testcase as documentation described
  • Loading branch information
Ronald Haring authored and Ronald Haring committed Jun 25, 2019
commit e5f6fb50dcb43d9f7fac5c1643ea1d3d95ab979d
15 changes: 15 additions & 0 deletions src/main/java/uk/org/lidalia/Slf4jUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package uk.org.lidalia;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Created on 25-6-2019.
*/
public class Slf4jUser {
private static final Logger logger = LoggerFactory.getLogger(Slf4jUser.class);

public void aMethodThatLogs() {
logger.info("Hello World!");
}
}
33 changes: 33 additions & 0 deletions src/test/java/uk/org/lidalia/Slf4jUserTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package uk.org.lidalia;

import org.junit.After;
import org.junit.Test;
import uk.org.lidalia.slf4jtest.TestLogger;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;

import java.util.Collections;

import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static uk.org.lidalia.slf4jtest.LoggingEvent.info;

/**
* Created on 25-6-2019.
*/
public class Slf4jUserTest {
Slf4jUser slf4jUser = new Slf4jUser();
TestLogger logger = TestLoggerFactory.getTestLogger(Slf4jUser.class);

@Test
public void aMethodThatLogsLogsAsExpected() {
slf4jUser.aMethodThatLogs();

assertThat(logger.getLoggingEvents(), is(Collections.singletonList(info("Hello World!"))));
}

@After
public void clearLoggers() {
TestLoggerFactory.clear();
}
}