问题描述
MyClass {
public static String myStaticmethod(HttpResponse httpResponse,ArrayList<Integer> list)
{
//Some Business logic
return "someString";
}
MyWorkerClass
MyWorkerClass {
public void myWorkerMethod throws MyCustomException{
//Some Business Logic
MyClass.myStaticmethod(httpResponse,list);
//Some more business logic
}
}
@RunWith(powermockrunner.class)
@PrepareForTest({MyClass.class})
public class MyWorkerClasstest {
@Test(expected = MyCustomException.class)
public void myWorkerMethodtest() throws MyCustomException{
//prepare required
mockStatic(MyClass.class);
when(MyClass.myStaticmethod(any(HttpResponse.class),any()).thenThrow(MyCustomException.class); //TARGET LINE
MyWorkerClass objectMyWorkerClass = new MyWorkerClass();
objectMyWorkerClass.myWorkerMethod();
}
}
当在 TARGET LINE 使用 any() 作为 ArrayList
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)