我是 spock 的新手,注意到设置:规范中的步骤仅限于该特定测试。与传统的 junit 方法类似,我如何在这些装置之间共享设置?
谢谢你!
def "setup with spock"() {
setup:
def message = new FooMessage()
def sut = new FooProcessor()
def builder = Mock(FooBuilder)
sut.setBuilder(builder)
when:
builder.buildFooUsing(_) >> {"bar"}
def result = sut.process(message)
then:
assert result == "bar"
}