Spock 的@Unroll 注释的目的是什么
What is the purpose of Spock's @Unroll annotation
我很难理解 Spock 测试框架的 @Unroll
注释。在文档中,提到了
Indicates that iterations of a data-driven feature should be made visible
as separate features to the outside world (IDEs, reports, etc.)
对我来说仍然没有多大意义。有人可以通俗地解释一下吗?
精彩的描述在 Spock's website。我应该首先查看它(实际上是第二位,仅次于 doc)。主要特点是,在失败的情况下,报告会指出失败的确切测试数据,而忽略其他情况。
an alternation in reporting
the output will look something like
maximum of two numbers[0] PASSED
maximum of two numbers[1] FAILED
Math.max(a, b) == c
| | | | |
| 7 0 | 7
42 false
maximum of two numbers[2] PASSED
@Unroll
是让每个数据驱动的迭代独立报告,如 Spock's website.
中所示
我想添加一些关于使用 @Unroll
.
的更多信息
如果您正在使用 @Unroll
,请同时自定义您的测试名称,这将有助于您的报告,例如:
@Unroll
def "maximum of #a and #b is #c"() { ... }
使用 @Unroll
时,每个数据驱动的迭代都将被计为 "test",这意味着您的测试计数将会增加。
如果您有数据驱动测试,请使用 @Unroll
。
我很难理解 Spock 测试框架的 @Unroll
注释。在文档中,提到了
Indicates that iterations of a data-driven feature should be made visible as separate features to the outside world (IDEs, reports, etc.)
对我来说仍然没有多大意义。有人可以通俗地解释一下吗?
精彩的描述在 Spock's website。我应该首先查看它(实际上是第二位,仅次于 doc)。主要特点是,在失败的情况下,报告会指出失败的确切测试数据,而忽略其他情况。
an alternation in reporting
the output will look something like
maximum of two numbers[0] PASSED
maximum of two numbers[1] FAILED
Math.max(a, b) == c
| | | | |
| 7 0 | 7
42 false
maximum of two numbers[2] PASSED
@Unroll
是让每个数据驱动的迭代独立报告,如 Spock's website.
中所示
我想添加一些关于使用 @Unroll
.
如果您正在使用 @Unroll
,请同时自定义您的测试名称,这将有助于您的报告,例如:
@Unroll
def "maximum of #a and #b is #c"() { ... }
使用 @Unroll
时,每个数据驱动的迭代都将被计为 "test",这意味着您的测试计数将会增加。
如果您有数据驱动测试,请使用 @Unroll
。