我正在为有活动的活动创建一个测试:
Logger.i("Response", new Gson().toJson(response));
它与消息崩溃:
java.lang.UnsupportedOperationException: Attempted to serialize java.lang.Class: web.services.Response. Forgot to register a type adapter?
我尝试将以下行添加到测试中,但它没有帮助:
Gson gson = new GsonBuilder().registerTypeAdapter(mock(Response.class).getClass(), new ClassTypeAdapter()).create();
P.S。我不能用powerMock来模拟Gson的最后一堂课。 如何解决这个问题?