模拟调用外部服务的静态方法

时间:2015-08-27 21:20:49

标签: mockito

我有一个类,它有一个在请求中传递的静态方法,并调用服务器来检索响应。 有没有办法模拟,因为它单元测试我不想进行服务调用。

String jsonResponse = getMeMyMoney(request)

protected static String getMeMyMoney(request)
{
response = executeService(request)
return response
}

我试过这个应该绕过这个方法,但它还是去了。任何人都知道如何做到这一点

doReturn("1").when(TestClass.getMeMyMoney("S"));

0 个答案:

没有答案