How to mock method e in Log

后端 未结 12 1690
忘掉有多难
忘掉有多难 2020-12-13 03:24

Here Utils.java is my class to be tested and following is the method which is called in UtilsTest class. Even if I am mocking Log.e method as shown below

 @B         


        
12条回答
  •  天涯浪人
    2020-12-13 04:02

    If your are using the org.slf4j.Logger, then just mocking the Logger in test class using PowerMockito worked for me.

    @RunWith(PowerMockRunner.class)
    public class MyClassTest {
    
    @Mock
    Logger mockedLOG;
    
    ...
    }
    

提交回复
热议问题