Skip to content

Instantly share code, notes, and snippets.

@wkorando
Last active July 30, 2018 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkorando/e44ad94980d9e44742ce68a081e4120f to your computer and use it in GitHub Desktop.
Save wkorando/e44ad94980d9e44742ce68a081e4120f to your computer and use it in GitHub Desktop.
public class TestStaticAppender {
@BeforeEach
public void clearLoggingStatements() {
StaticAppender.clearEvents();
}
@Test
public void testAssertingLoggingStatementsA() {
LogProducingService service = new LogProducingService();
service.writeSomeLoggingStatements("A");
assertThat(StaticAppender.getEvents()).extracting("message").containsOnly("Let's assert some logs! A",
"This message is in a separate thread");
}
@Test
public void testAssertingLoggingStatementsB() {
LogProducingService service = new LogProducingService();
service.writeSomeLoggingStatements("B");
assertThat(StaticAppender.getEvents()).extracting("message").containsOnly("Let's assert some logs! B",
"This message is in a separate thread");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment