当前位置:网站首页>EasyMock日记1[通俗易懂]
EasyMock日记1[通俗易懂]
2022-07-31 12:50:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
private PayController payController;
private HttpServletRequest request;
private User user;
private HttpSession session;
@Before
public void before(){
payController=new PayController();
user=new User();
user.setUsername("18350591915");
user.setUseNo("4f62f0e5516346748843df6131072ae0");
}
@Test
public void Testalipay_notify(){
request=EasyMock.createMock(HttpServletRequest.class);
session=EasyMock.createMock(HttpSession.class);
EasyMock.expect(request.getParameter("type")).andReturn("1");
EasyMock.expect(request.getParameter("money")).andReturn("1");
EasyMock.expect(request.getParameter("paymentId")).andReturn("1");
//EasyMock.expect((User)request.getSession().getAttribute("user")).andReturn(user);
//这句话不知道为什么不能实现``
EasyMock.expect(request.getSession()).andReturn(session);
EasyMock.expect(session.getAttribute("user")).andReturn(user);
EasyMock.replay(request);
assertNotNull(payController.recharge(null, request));
EasyMock.verify(request);
}
参考http://blog.csdn.net/chjttony/article/details/14522771[参考地址](http://blog.csdn.net/chjttony/article/details/14522771%20%E5%8F%82%E8%80%83%E5%8D%9A%E5%AE%A2easymock)
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128637.html原文链接:https://javaforall.cn
边栏推荐
- PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer
- 电商rpa是什么意思?跟电商rpi是一个意思吗?
- golang八股文整理(持续搬运)
- Introduction to using NPM
- sqlalchemy determines whether a field of type array has at least one consistent data with an array
- chroot命令
- ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
- SAP message TK 248 solved
- 五种数据提交方式的优化
- 365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal
猜你喜欢
anaconda虚拟环境安装pytorch gpu版本
365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
函数递归1.0
Character Functions and String Functions
【CPU设计实战】简单流水线CPU设计
alert(1) (haozi.me)靶场练习
深入浅出边缘云 | 4. 生命周期管理
AMBA APB学习记录(AMBA 3/4)
想吃菌子,当然是自己上山找了
随机推荐
ECCV2022:在Transformer上进行递归,不增参数,计算量还少!
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
golang中使用泛型
立方体IV(暑假每日一题 10)
FastAPI encapsulates a generic response
PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer
Character Functions and String Functions
sqlalchemy 判断一个array 类型的字段是否和一个array有至少一个一致的数据
CentOS7 —— yum安装mysql
全动力学约束的机器人高效时间最优轨迹规划
Full GC (Ergonomics)排查分析
函数递归1.0
一文吃透哈希表
Use docker to build mysql master-slave
【CPU设计实战】简单流水线CPU设计
PAT exam summary (exam experience)
Getting started with jmeter performance testing steps (performance testing tool jmeter)
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
深度学习基本概念