Search
 
SCRIPT & CODE EXAMPLE
 

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!");
    }
}
Comment

assert log in unit testing

public class FooService {

    private static final Logger LOGGER = LoggerFactory.getLogger(FooService.class);

    public void sayHello() {
        LOGGER.warn("Congratulations, you are pregnant!");
    }

}
Comment

PREVIOUS NEXT
Code Example
Java :: first character string number java 
Java :: arraylist to linkedlist java 
Java :: Changing background color of selected item in recyclerview 
Java :: how to initialize an empty array in java 
Java :: how junit test getter and setter 
Java :: how to create a constructor in java 
Java :: how to run java files 
Java :: java repeat method 
Java :: generic classes in java 
Java :: java date and time 
Java :: remove last character from stringbuffer 
Java :: in java how to compare two strings 
Java :: java program to Check given String is contians number or not 
Java :: how to get a character in java in ascii 
Java :: how to change custom font to bold italic in java 
Java :: spark write partitionby 
Java :: not equal java 
Java :: javafx get the controller of a pane 
Java :: JFrame frame = new JFrame (); 
Java :: actuator spring boot 
Java :: reverse negative number 
Java :: Random Float in java 
Java :: If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration. 
Java :: hashmap 
Java :: remove all element in a list java 
Java :: remove whitespaces 
Java :: maximum arrays size in java 
Java :: select list of values from db java 
Java :: change text size java 
Java :: nextint java 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =