【发布时间】:2017-03-29 06:40:04
【问题描述】:
我编写了以下规范:
class Spec extends Specification {
def 'does not work if interaction declared as Set without parens'() {
given:
def holder = Mock(Holder)
def expected = [1, 2, 3, 3]
when:
def output = holder.value()
then:
output == [1, 2, 3] as Set
// 1 * holder.value() >> expected.toSet() // 1
1 * holder.value() >> expected as Set // 2
// 1 * holder.value() >> (expected as Set) // 3
}
class Holder {
def value() {
}
}
}
问题在于它只有在holder.value() 交互被定义为1 或3 行时才有效。当它在 2 行中定义时,它会失败并出现以下错误:
Condition not satisfied:
output == [1, 2, 3] as Set
| |
null false
为什么?看起来可能有一些解析器错误。
【问题讨论】: