Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java cucumber jvm:截取特性顶部的注释_Java_Groovy_Cucumber Jvm - Fatal编程技术网

Java cucumber jvm:截取特性顶部的注释

Java cucumber jvm:截取特性顶部的注释,java,groovy,cucumber-jvm,Java,Groovy,Cucumber Jvm,我正在使用cumberjvm(Groovy),我想知道是否有可能在特性之上截取一个定制的注释。例: @MyAnnotation Feature: Something here //and somewhere a method like this: def doSomethingForMyAnnotation() {...} 如果不可能,如果在运行特定功能之前有其他方法来运行某些代码(在这之前没有@,这与场景有关)。当然,您可以在Groovy代码中引用任何自定义注释,如下所示: @Before

我正在使用cumberjvm(Groovy),我想知道是否有可能在特性之上截取一个定制的注释。例:

@MyAnnotation
Feature: Something here

//and somewhere a method like this:
def doSomethingForMyAnnotation() {...}

如果不可能,如果在运行特定功能之前有其他方法来运行某些代码(在这之前没有@,这与场景有关)。

当然,您可以在Groovy代码中引用任何自定义注释,如下所示:

@Before("@MyAnnotation")
public void beforeMyAnnotation() {
    // Do something
}

@After("@MyAnnotation")
public void afterMyAnnotation() {
    // Do something
}
顺便说一句,这些都是标记的钩子,你也可以使用多个。请看一个简单的例子