Spock在调用getEstimatedNumIterations()时返回了不正确/默认的值。

huangapple go评论40阅读模式
英文:

Spock returning incorrect/default value for a getEstimatedNumIterations() call

问题

IterationInfo类中存在一个名为getEstimatedNumIterations()的方法,根据其javadoc,它将返回拥有功能的当前执行的总迭代次数。在旧版本的Spock(2.0-groovy-3)中,这个方法按预期工作:

(简单而略显荒谬的PoC):



def "Iteration test - #x"() {
  given: "a dumb way to illustrate the problem"
  println "Estimate: " + this.getSpecificationContext().getCurrentIteration().getEstimatedNumberOfIterations()

  expect:
  true

  where:
  x << [1, 2, 3]

}

打印Est: 3(x3)

然而,在最新的稳定版本(2.3-groovy-4)中,相同的规范产生以下结果:
Est: -1(x3)

我可以看到从2.0到2.3有相当多的框架改进,特别是涉及迭代构造。是否有其他方法来获取功能的估计迭代次数?我主要在一些自定义注解中使用这个功能。

英文:

On the IterationInfoclass there exists a method called getEstimatedNumIterations() which, based on its javadoc, will return the total number of iterations for the ongoing execution of the owning feature. In older versions of Spock (2.0-groovy-3), this method worked as expected:

(simple, slightly absurd PoC):



def "Iteration test - #x"() {
  given: "a dumb way to illustrate the problem"
  println "Estimate: " + this.getSpecificationContext().getCurrentIteration().getEstimatedNumberOfIterations()

  expect:
  true

  where:
  x << [1, 2, 3]

}

prints Est: 3 (x3)

However, with the latest stable release (2.3-groovy-4) that same spec produces the following:
Est: -1 (x3)

I can see there was a decent amount of framework improvements from 2.0 -> 2.3, especially involving iteration construction. Is there any other way to get the estimated number of iterations for a feature? I am primarily using this in a few custom annotations.

答案1

得分: 1

这是Spock框架中的一个回归问题,我已经创建了一个问题

英文:

This is a regression in the Spock Framework, I've created an issue.

huangapple
  • 本文由 发表于 2023年2月13日 23:34:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75438007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定