【发布时间】:2016-05-21 09:30:56
【问题描述】:
Spock 没有检测到 doTip 方法调用
(我需要共享一些“where”块。)
使用最新 groovy 和 spock。
为什么这段代码是错误的?
如何解决?
import spock.lang.Shared
import spock.lang.Specification
class Test extends Specification {
def controller
@Shared
String g = ""
@Shared
def tip = Mock(Tip)
def "test"() {
controller = new TController(tip: tip)
when:
controller.transform(g)
then:
1 * tip.doTip(_)
}
}
class Tip {
def doTip(String f) {}
}
class TController {
Tip tip
def transform(String g) {
tip.doTip(g)
}
}
【问题讨论】:
标签: unit-testing testing groovy spock