英文:
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 IterationInfo
class 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论