How can I mock private static method with PowerMockito?

后端 未结 3 1437
渐次进展
渐次进展 2020-12-08 15:07

I\'m trying to mock private static method anotherMethod(). See code below

public class Util {
    public static String method(){
        return          


        
3条回答
  •  鱼传尺愫
    2020-12-08 15:56

    If anotherMethod() takes any argument as anotherMethod(parameter), the correct invocation of the method will be:

    PowerMockito.doReturn("abc").when(Util.class, "anotherMethod", parameter);
    

提交回复
热议问题