Skip to content

Instantly share code, notes, and snippets.

@tzachz
Created July 22, 2013 07:22
Show Gist options
  • Save tzachz/6051904 to your computer and use it in GitHub Desktop.
Save tzachz/6051904 to your computer and use it in GitHub Desktop.
logback verifier usage
import ch.qos.logback.classic.Level;
import com.kenshoo.test.LogbackVerifier;
import org.junit.Rule;
import org.junit.Test;
public class MyTest {
@Rule
public LogbackVerifier logbackVerifier = new LogbackVerifier();
private MyTestedService service = new MyTestedService();
@Test
public void verifyGoodScenario() throws Exception {
logbackVerifier.expectMessage(Level.INFO, "it worked");
service.doSomething("good input");
}
@Test
public void verifyBadScenario() throws Exception {
logbackVerifier.expectMessage(Level.ERROR, "something went wrong", IllegalArgumentException.class);
service.doSomething("bad input");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment