当前位置:网站首页>Spock约束-调用频率/目标/方法参数
Spock约束-调用频率/目标/方法参数
2022-06-23 06:23:00 【qq_37279783】
调用频率约束(cardinality)
1 * subscriber.receive("hello") // exactly one call
0 * subscriber.receive("hello") // zero calls
(1..3) * subscriber.receive("hello") // between one and three calls (inclusive)
(1.._) * subscriber.receive("hello") // at least one call
(_..3) * subscriber.receive("hello") // at most three calls
_ * subscriber.receive("hello") // any number of calls, including zero
// (rarely needed; see 'Strict Mocking')
目标约束(target constraint)
1 * subscriber.receive("hello") // a call to 'subscriber'
1 * _.receive("hello") // a call to any mock object
方法约束(method constraint)
1 * subscriber.receive("hello") // a method named 'receive'
1 * subscriber./r.*e/("hello") // a method whose name matches the given regular expression (here: method name starts with 'r' and ends in 'e')
参数约束(argument constraint)
1 * subscriber.receive("hello") // an argument that is equal to the String "hello"
1 * subscriber.receive(!"hello") // an argument that is unequal to the String "hello"
1 * subscriber.receive() // the empty argument list (would never match in our example)
1 * subscriber.receive(_) // any single argument (including null)
1 * subscriber.receive(*_) // any argument list (including the empty argument list)
1 * subscriber.receive(!null) // any non-null argument
1 * subscriber.receive(_ as String) // any non-null argument that is-a String
1 * subscriber.receive(endsWith("lo")) // any non-null argument that is-a String
1 * subscriber.receive({ it.size() > 3 && it.contains('a') })
// an argument that satisfies the given predicate, meaning that
// code argument constraints need to return true of false
// depending on whether they match or not
// (here: message length is greater than 3 and contains the character a)
边栏推荐
- C language learning summary
- Deep learning series 47: Super sub model real esrgan
- What you need to know about five insurances and one fund
- [project training] multi segment line expanded to parallel line
- 307. area and retrieval - array modifiable
- Why can't the index of JS array use negative numbers
- 313. super ugly number
- excel高级绘图技巧100讲(八)-Excel绘制WIFI图
- 云原生落地进入深水区,博云容器云产品族释放四大价值
- .h5文件忘记数据库名字,使用h5py打印
猜你喜欢

对二进制的某一位操作
![[project training] multi segment line expanded to parallel line](/img/f2/ee4985fd2454bf00d600e34a818f2d.png)
[project training] multi segment line expanded to parallel line

Intentional shared lock, intentional exclusive lock and deadlock of MySQL

407-栈与队列(232.用栈实现队列、225. 用队列实现栈)

正则表达式图文超详细总结不用死记硬背(上篇)
![[STL] summary of map usage of associated containers](/img/1d/1b6488ea47face0548500b1e1ec60d.png)
[STL] summary of map usage of associated containers

MySQL(八) — 执行计划(Explain)详解

启发式的搜索策略
![[STL] summary of deque usage of sequential containers](/img/33/65c54d14697ee43b2655ea1255d67d.png)
[STL] summary of deque usage of sequential containers

Project_ Filter to solve Chinese garbled code
随机推荐
用户态和内核态
How to migrate virtual machines from VirtualBox to hype-v
MySQL MVCC多版本并发控制
[STL] summary of map usage of associated containers
899. ordered queue
pspnet完整代码实现
滚动播报效果的实现
306. Addenda
307. 区域和检索 - 数组可修改
闫氏DP分析法
407 stack and queue (232. implementing queue with stack, 225. implementing stack with queue)
TensorFlow中的数据类型
宝塔忘记密码
如何达到高效的网络信息传播
Initialization layer implementation
About professional attitude
896. monotonic sequence
[bull Chinese document] queue package used to process distributed jobs and messages in nodejs
SSTable详解
[system] right click the desktop icon. After turning around, the Explorer will crash and the desktop will be refreshed