在最近的代码审查中,出现了关于 @Unroll 注释属于类级别还是方法级别的问题。该类的大多数方法(但不是全部)都需要 @Unroll。如果在类级别声明并且并非类的所有方法都需要它,声明 @Unroll 是否会导致任何性能损失?
最佳答案
@Unroll 注释旨在用于方法级别。但它也可以在类级别上使用,如 Unroll.java JavaDoc comments 中所示。 :
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.
关于grails - Spock @Unroll 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30577376/