assert log in unit testing

Solutions on MaxInterview for assert log in unit testing by the best coders in the world

showing results for - "assert log in unit testing"
Jacob
24 Aug 2017
1public class FooServiceTest {
2
3    private LogCaptor logCaptor = LogCaptor.forClass(FooService.class);
4
5    @Test
6    public void logInfoAndWarnMessages() {
7        FooService fooService = new FooService();
8        fooService.sayHello();
9
10        assertThat(logCaptor.getWarnLogs())
11            .contains("Congratulations, you are pregnant!");
12    }
13}
14
Jarrod
24 Oct 2016
1public class FooService {
2
3    private static final Logger LOGGER = LoggerFactory.getLogger(FooService.class);
4
5    public void sayHello() {
6        LOGGER.warn("Congratulations, you are pregnant!");
7    }
8
9}
10
similar questions
queries leading to this page
assert log in unit testing