当前位置:网站首页>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)
边栏推荐
猜你喜欢

用户态和内核态

MySQL Redo log Redo log

JUnit unit test reports an error org junit. runners. model. InvalidTestClassError: Invalid test class ‘xxx‘ . No runnable meth

How to migrate virtual machines from VirtualBox to hype-v

深度学习系列46:人脸图像超分GFP-GAN

PSP代码实现

EndNote20使用教程分享(未完

Regular expression graph and text ultra detailed summary without rote memorization (Part 1)

云原生落地进入深水区,博云容器云产品族释放四大价值

闫氏DP分析法
随机推荐
306. Addenda
[shell] tree command
TP6+Redis+think-queue+Supervisor实现进程常驻消息队列/job任务
C # how to obtain DPI and real resolution (can solve the problem that has been 96)
Why does TCP protocol shake hands three times instead of two?
滚动播报效果的实现
MySQL MVCC多版本并发控制
MySQL重做日志 redo log
312. 戳气球
deeplab v3 代码结构图
System permission program cannot access SD card
900. RLE 迭代器
excel高级绘图技巧100讲(八)-Excel绘制WIFI图
300. 最长递增子序列
QT designer cannot modify the window size, and cannot change the size by dragging the window with the mouse
898. 子数组按位或操作
900. RLE iterator
JUnit unit test reports an error org junit. runners. model. InvalidTestClassError: Invalid test class ‘xxx‘ . No runnable meth
MySQL总结
【***数组***】