如何mock网络response
4 回答

慕斯709654
TA贡献1840条经验 获得超5个赞
在servlet中有以下两种方法: public void doGet(HttpServletRequest request, HttpServletResponse response) public void doPost(HttpServletRequest request, HttpServletResponse response) 可以直接使用request和response不需要创建的!

扬帆大鱼
TA贡献1799条经验 获得超9个赞
传统的JMock是无法Mock静态方法的,但是Jmockit能够很好地Mock类的静态方法。
[java] view plain copy
package features.jmockit.staticmock;
public class StaticTarget {
public static int m1() {
throw new RuntimeException();
}
public static String m2() {
throw new RuntimeException();
}
}
添加回答
举报
0/150
提交
取消