Spock @Unroll批注 [英] Spock @Unroll annotation
问题描述
在最近的代码审查中,有关@Unroll批注属于类级别还是方法级别的问题浮出水面.所涉及的类的大多数方法都需要@Unroll,但并非所有方法都需要.如果在类级别声明@Unroll,并且所有类的方法都不需要,则声明@Unroll是否会导致性能下降?
During a recent code review, the question came up regarding whether the @Unroll annotation belongs at the class level or the method level. The class in question requires @Unroll on most of its methods but not all of them. Does declaring @Unroll incur any performance penalties if declared at the class level and not all methods of the class require it?
推荐答案
The @Unroll annotation is intended to be used on the method level. But it can also be used on the class level as indicated in the Unroll.java JavaDoc comments:
{@ code Unroll}批注也可以放在spec类上.这与将其放置在尚未使用{@code Unroll}进行注释的每个数据驱动的特征方法上具有相同的效果.通过将命名模式嵌入方法名称中,每个方法仍然可以拥有自己的模式.
The {@code Unroll} annotation can also be put on a spec class. This has the same effect as putting it on every data-driven feature method that is not already annotated with {@code Unroll}. By embedding the naming pattern in the method names, each method can still have its own pattern.
这篇关于Spock @Unroll批注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!