当前位置:网站首页>Spock constraint - call frequency / target / method parameters
Spock constraint - call frequency / target / method parameters
2022-06-23 07:15:00 【qq_ thirty-seven million two hundred and seventy-nine thousand 】
Call frequency constraint (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')
Goal constraints (target constraint)
1 * subscriber.receive("hello") // a call to 'subscriber'
1 * _.receive("hello") // a call to any mock object
Method constraints (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')
Parameter constraints (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)
边栏推荐
猜你喜欢

407 stack and queue (232. implementing queue with stack, 225. implementing stack with queue)

UNET code implementation

Analyzing the creation principle in maker Education

How to migrate virtual machines from VirtualBox to hype-v

如何优雅的快速下载谷歌云盘的大文件 (二)

用户态和内核态

GINet

MySQL mvcc multi version concurrency control

junit单元测试报错org.junit.runners.model.InvalidTestClassError: Invalid test class ‘xxx‘ .No runnable meth

Project_ Filter to solve Chinese garbled code
随机推荐
云原生落地进入深水区,博云容器云产品族释放四大价值
309. 最佳买卖股票时机含冷冻期
The List
RFID数据安全性实验:C#可视化实现奇偶校验、CRC冗余校验、海明码校验
318. maximum word length product
Regular expression graph and text ultra detailed summary without rote memorization (Part 1)
898. 子数组按位或操作
Pagoda forgot password
316. 去除重复字母
Flannel 工作原理
细说Idea那些骚操作
别找了诸位 【十二款超级好用的谷歌插件都在这】(确定不来看看?)
322. 零钱兑换
Spock约束-调用频率/目标/方法参数
paddle版本问题
codeforce 158B Taxi
聚焦行业,赋能客户 | 博云容器云产品族五大行业解决方案发布
313. super ugly number
20BN-Jester完整数据集下载
896. 单调数列