当前位置:网站首页>Spock sub piling
Spock sub piling
2022-06-23 07:15:00 【qq_ thirty-seven million two hundred and seventy-nine thousand 】
Stubbing It is the behavior that enables the collaborator to respond to method calls in some way . When you stub a method , Don't care about the number of calls to this method , Just hope it returns some values when called , Or perform some reaction .
subscriber.receive(_) >> "ok"
| | | |
| | | response generator
| | argument constraint
| method constraint
target constraint
Such as :subscriber.receive(_) >> "ok" meaning , No matter what instance , What parameters , call receive Methods return strings ok
Return fixed value
Use >> Operator , Return fixed value
subscriber.receive(_) >> "ok"
Return value sequence
Return a sequence , Iterates and returns the specified value in turn . As shown below , The first call returns ok, The second call returns error, And so on
subscriber.receive(_) >>> ["ok", "error", "error", "ok"]
Calculate the return value dynamically
subscriber.receive(_) >> { args -> args[0].size() > 3 ? "ok" : "fail" }
subscriber.receive(_) >> { String message -> message.size() > 3 ? "ok" : "fail" }
Produce reaction
subscriber.receive(_) >> { throw new InternalError("ouch") }
Chain response
subscriber.receive(_) >>> ["ok", "fail", "ok"] >> { throw new InternalError() } >> "ok"
边栏推荐
- TP6+Redis+think-queue+Supervisor实现进程常驻消息队列/job任务
- Xshell7 Download
- 900. RLE 迭代器
- 产品-Axure9(英文版),原型设计后台动态二级菜单显示内容
- Arthas-thread命令定位线程死锁
- junit单元测试报错org.junit.runners.model.InvalidTestClassError: Invalid test class ‘xxx‘ .No runnable meth
- 100 GIS practical application cases (79) - key points of making multi plan integrated base map
- [game theory] basic knowledge
- ldconfig 命令
- 312. 戳气球
猜你喜欢
随机推荐
用户态和内核态
897. incremental sequential search tree
leetcode210. 课程表 II 207. 课程表 拓扑排序 dfs bfs
初始化层实现
How to achieve efficient network information dissemination
Page embedded iframe click browser back problem
NPM download error NPM err code error
Configuration and compilation of mingw-w64, msys and ffmpeg
别找了诸位 【十二款超级好用的谷歌插件都在这】(确定不来看看?)
309. the best time to buy and sell stocks includes the freezing period
GINet
直播回顾 | 传统应用进行容器化改造,如何既快又稳?
Xshell7 Download
[game theory] basic knowledge
Analyzing the creation principle in maker Education
Vs2013 ffmpeg environment configuration and common error handling
Pspnet complete code implementation
Spock约束-调用频率/目标/方法参数
Pagoda forgot password
如何达到高效的网络信息传播









