如何为Spock块添加注释?

时间:2014-10-21 09:43:55

标签: groovy annotations spock

我正在尝试创建一个可以添加到Groovy类,spock功能和spock块的注释。 'when'块之前的注释失败,因为spock语言解析器无法识别它。有谁知道我的问题的解决方案?

@MyAnnotation("Info")
class MySpec extends Specification {

  @MyAnnotation("Info")
  def setupSpec () {
    //...
  }

  @MyAnnotation("Info")
  def "test feature X"() {  

    @MyAnnotation("Info")
    when:
      //...
    then:
      //...
  } 
}

感谢您的帮助!

干杯, 丹尼斯

1 个答案:

答案 0 :(得分:0)

简短的回答是你不能。

whenthenexpectwhere等基本上是labels