spock文档指出你可以将then块的断言提取到其他方法,并assert在每个断言之前添加关键字.
我还想提取与helper方法的交互.我尝试用interaction闭包块包装交互但是没有用.
可能吗?如果是如何实现的呢?
use*_*192 14
事实证明你可以.你必须用交互包装辅助方法调用:
then:
interaction {
helperMethod()
}
Run Code Online (Sandbox Code Playgroud)
然后你可以将交互放在这样的辅助方法中:
def helperMethod() {
1 * someObj.getInt() >> 2
}
Run Code Online (Sandbox Code Playgroud)
我做了相反的事情(在交互中包裹帮助方法体),这就是为什么它不起作用
| 归档时间: |
|
| 查看次数: |
786 次 |
| 最近记录: |