在这个 groovy 语句中 >> 和 1* 是什么意思?
what does >> and 1* means in this groovy statement?
我正在做 grails/groovy 项目,在阅读他们的测试文档时遇到了这行代码
1 * myService.prova() >> { true }
我无法理解 1 * 在这里是什么意思,因为 >> 是右移运算符,它在这里是什么意思?我搜索了很多但无法得到任何适当的解释。
Grails Test Documenation
这不是 groovy 本身,而是名为 Spock 的测试框架(它在 Groovy 开发人员中非常流行,有充分的理由:-) - http://spockframework.github.io/spock/docs/1.0/index.html
这个表达式特别是一种指示 Spock 它应该期待在 myService
中对方法 prova
的一次调用,并且这个调用应该被模拟为 return true
。请参阅 Interaction based testing ,特别是名为 Combining Mocking and Stubbing.
的部分
我正在做 grails/groovy 项目,在阅读他们的测试文档时遇到了这行代码
1 * myService.prova() >> { true }
我无法理解 1 * 在这里是什么意思,因为 >> 是右移运算符,它在这里是什么意思?我搜索了很多但无法得到任何适当的解释。 Grails Test Documenation
这不是 groovy 本身,而是名为 Spock 的测试框架(它在 Groovy 开发人员中非常流行,有充分的理由:-) - http://spockframework.github.io/spock/docs/1.0/index.html
这个表达式特别是一种指示 Spock 它应该期待在 myService
中对方法 prova
的一次调用,并且这个调用应该被模拟为 return true
。请参阅 Interaction based testing ,特别是名为 Combining Mocking and Stubbing.