当结果很复杂时,如何在Spock中使用数据表?

时间:2018-02-22 08:44:39

标签: groovy spock

例如,如果我写下面的代码:

expect:
methodToTest(from, to) == result
where:
from          | to            | result
1508446800000 | 1509483600000 | (Entry) [1506805200000L, 1512075600000L]

其中methodToTest(long from, long to)返回Entry 我收到错误:

'or' in 'org.codehaus.groovy.runtime.DefaultGroovyMethods' cannot be applied to (Entry).

2 个答案:

答案 0 :(得分:1)

你不能在表格中使用构造函数吗?

where:
from          | to            | result
1508446800000 | 1509483600000 | new Entry(1506805200000L, 1512075600000L)

答案 1 :(得分:-1)

解决方案是替换

from          | to            | result
1508446800000 | 1509483600000 | new Entry(1506805200000L, 1512075600000L)

from          | to            || result
1508446800000 | 1509483600000 || new Entry(1506805200000L, 1512075600000L)