Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

assert log in unit testing

public class FooServiceTest {

    private LogCaptor logCaptor = LogCaptor.forClass(FooService.class);

    @Test
    public void logInfoAndWarnMessages() {
        FooService fooService = new FooService();
        fooService.sayHello();

        assertThat(logCaptor.getWarnLogs())
            .contains("Congratulations, you are pregnant!");
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #assert #log #unit #testing
ADD COMMENT
Topic
Name
6+6 =