简体   繁体   中英

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. 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).

Of course, you can refer to any of your custom annotations like this in your Groovy-code:

@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. Have look here for a quick example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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