如何获得斯波克注释闭包结果



我想知道如何获取 IgnoreIf spock 注释的布尔值。

例如,在我的脚本中,我可能有这样的东西:

@IgnoreIf({someBooleanMethod()})
def "Some Feature Method"(){
    // code and stuff
}

我还有一个自定义的 spock 扩展。在那个扩展中,我有这个:

//iterates over each feature method in a spec
for (FeatureInfo feature : spec.getFeatures()){
    if(feature.getFeatureMethod().reflection.isAnnotationPresent(IgnoreIf.class)&&feature.getFeatureMethod().reflection.getAnnotation(IgnoreIf.class).value()){
        //some more code goes here
    }
}
我想评估包含 IgnoreIf 闭包

的每个功能方法的 IgnoreIf 闭包。如果我没记错的话,feature.getFeatureMethod().reflection.getAnnotation(IgnoreIf.class).value()应该给我给定注释中的衣裳,但我不知道如何实际评估我在闭包内部的someBooleanMethod,看看它是真的还是假的。我该怎么做?

new IgnoreIfExtension().visitFeatureAnnotation(feature.getFeatureMethod().reflection.getAnnotation(IgnoreIf.class), feature)

这就是我所做的。 如果 IgnoreIf 条件为 true,则会将其设置为自行跳过

最新更新