简体   繁体   English

cucumber-jvm:截取特征顶部的注释

[英]cucumber-jvm: intercepting annotations on top of feature

I am using Cucumber-JVM (Groovy) and I was wondering if it is possible intercepting a customized annotation on top of a feature. 我正在使用Cucumber-JVM(Groovy),我想知道是否有可能在功能上拦截自定义注释。 Ex: 例如:

@MyAnnotation
Feature: Something here

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

and if it is not possible, if there is an alternative to run some code before a specific feature is run (no @Before that is relative to Scenario). 如果不可能,在运行特定功能之前是否有替代方法可以运行某些代码(没有相对于Scenario的@Before)。

Of course, you can refer to any of your custom annotations like this in your Groovy-code: 当然,您可以在Groovy代码中引用这样的任何自定义注释:

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

@After("@MyAnnotation")
public void afterMyAnnotation() {
    // Do something
}

Those are tagged hooks BTW, you can also use more than one. 那些是标签挂钩BTW,你也可以使用多个。 Have look here for a quick example. 在这里看一个快速的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM