什么标志 - >在spock框架中意味着什么?

时间:2015-03-03 11:16:12

标签: spock

有人能解释一下我的意思是什么 - >在spock框架中?

对于exaple,我们有如下代码:

given:
    UserService service = Stub()
    service.save({ User user -> 'Michael' == user.name }) >> {
        throw new IllegalArgumentException("We don't want you here, Micheal!")
    }

我知道这段代码是做什么的,但我不知道角色如何签名 - >在这段代码中。

1 个答案:

答案 0 :(得分:5)

Spock框架假定对Groovy语言有基本的理解,有时会出现更复杂的Groovy部分(如示例所示)。

->表示关闭,如Groovy documentation中所述。

例如,Groovy中的闭包可能如下所示:

def greeting = "Hello"
def sayHiTo = { name -> greeting + " " + name }
println sayHiTo("user3664097")
相关问题