spockframework/spock
在 GitHub 查看Mocking: Variables of Closure type aren't evaluated as code args
Open
#591 建立於 2016年5月31日
component:docshelp wanted
倉庫指標
- Star
- (3,457 star)
- PR 合併指標
- (平均合併 2天 8小時) (30 天內合併 11 個 PR)
描述
def beatIt = {
def result = (it >= now)
Thread.sleep(1)
now = System.currentTimeMillis()
return result
}
when:
task.execute(context)
then:
1 * loggingService.startJob(job, _, beatIt) >> jobExec // doesn't work
1 * loggingService.startJob(job, _, { beatIt(it) }) >> jobExec // works
Example is from one of my tests, where I discovered it.
From what I can tell, it is related to how you decide what is a code argument in the InteractionRewriter.addArg method. Maybe try also inspecting any VariableExpressions for closure type?