我想为我的代码编写junit 5测试用例,但无法覆盖此方法中的第5-7行,请有人帮助我吗
1. public class StudnetIno{
2. public void log(Student student) throws JsonProcessingException
3. {
4. if(Loggin.isDebugEnabled(this) && Utility.isProduction()){
5. ObjectMapper map = new ObjectMapper();
6. map.getFactory().setCharacterEscapes(new HTMLCharacterEscapes());
7. Loggin.debugMessage(this,map.writerWithDefaultPrettyPrinter().writeValueAsString(student));
8. }
9. }
***注意:***isDebugEnable()和isProduction()方法是公共静态方法
@Test
void testLog() throws JsonProcessingException{
StudnetIno studnetIno = new StudnetIno();
studnetIno.log(new Student());
ObjectMapper map = new ObjectMapper();
assertEquals("", map.writerWithDefaultPrettyPrinter().writeValueAsString(student))
}
这就是我的测试用例
1条答案
按热度按时间wmvff8tz1#
您需要模拟静态方法
isDebugEnabled()
和isProduction
。