0
我想知道如何獲得IgnoreIf spock註釋的布爾值。如何獲得Spock註釋關閉結果
舉例來說,在我的劇本我可能有這樣的事情:
@IgnoreIf({someBooleanMethod()})
def "Some Feature Method"(){
// code and stuff
}
我也有一個自定義的斯波克擴展。在extention我有這樣的:
//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()
應該給我從給定的註釋clouse,但我不知道如何實際評估我在閉合內有someBooleanMethod
,看看它是真的還是假的。我怎麼做?
只需查看擴展的代碼org.spockframework.runtime.extension.builtin.IgnoreIfExtension –
@LeonardBrünings我假設您指的是'evaluateCondition在那個班上找到的方法。它是一種非靜態方法,所以如何獲取該對象的實例以便我可以調用該方法 – switch201