我想在Spock框架的功能方法名称中添加序列号。我怎样才能做到这一点?
给出一个代码片段以供澄清:
class Test extends Specification {
static def count = 0;
def setup() {
count++
}
def '${count} This is first scenario'() {
...
}
def '${count} This is second scenario'() {
...
}
}
运行此代码后,它会显示在报告中:
${count} This is first scenario
${count} This is second scenario
但我期待:
1 This is first scenario
2 This is second scenario
最佳答案
这应该有效:
@Unroll
def "(#iterationIndex) test name" { ... }
UPD:它以前称为#iterationCount
,但现在是#iterationIndex
,请参阅https://spockframework.org/spock/docs/2.0-M5/migration_guide.html
关于string - 如何在Spock框架中的功能方法名称中添加数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36169721/