Mock private static final field using mockito or Jmockit

前端 未结 4 1127
感情败类
感情败类 2020-12-05 09:31

I am using private static final LOGGER field in my class and I want LOGGER.isInfoEnabled() method to return false. How can

4条回答
  •  星月不相逢
    2020-12-05 10:14

    I think mockito or jMockit cant mock static final classes as they try to override the methods while unit testing. However, powerMockito can as it uses Reflection and mocks the static final class/methods.

提交回复
热议问题