Power Mock to mock static constructor failed

时间:2016-03-29 08:05:02

标签: android powermockito

我正在使用power mock来为静态构造函数

创建和初始化对象
PowerMockito.when(RequestHandler.getInstance(coordinatorLayout,getSystemContext(‌​))).thenReturn(handler); 

但在运行测试时我获得了:

  

无法模拟RequestHandler对象的构造   cz.msebera.android.httpclient.conn.ssl.SSLInitializationException

 public RequestHandler(){
       this.client = new AsyncHttpClient();
    }

    public static RequestHandler getInstance(CoordinatorLayout coordinatorLayout,Context context){
        if(instance == null){
            instance = new RequestHandler();
        }
        instance.coordinatorLayout = coordinatorLayout;
        instance.context=context;
        notificationProvider=new NotificationProvider(coordinatorLayout);
        instance.myUserSessionManager=new MyUserSessionManager(context);
        return instance;
    }

`

0 个答案:

没有答案