Geb Groovy 和 spock 大师,您能帮我理解为什么下面的代码对我不起作用(变量 'closr' 给出一个空值)
import geb.Browser
import spock.lang.Specification
class somclass extends Specification{
def clos = {
go()
}
def Browser driveit(Browser browser, Closure script) {
script.setDelegate(browser)
script()
browser
}
}
objnew = new somclass()
def closr = objnew.clos
objnew.driveit(new Browser(),closr)
尽管
import geb.Browser
class somclass {
def clos = {
go()
}
def Browser driveit(Browser browser, Closure script) {
script.setDelegate(browser)
script()
browser
}
}
objnew = new somclass()
def closr = objnew.clos
objnew.driveit(new Browser(),closr)
这个对我有用(变量'closr'返回了闭包)。?第二个的唯一区别是我删除了扩展 spock 规范