简体   繁体   中英

cucumber -skip before hook in certain examples

In my case some features are launching the UI before every step because of before feature hook which has a logic to launch URL in browser but in some features I just need to perform some post request and does not want to launch any URL .So is there any way to skip executing this before hook.

Thanks in advance!!!

@Before()
public void priorToScenarioExecution(Scenario scenario) {
    if (scenario.getId().equals("Some feature;scenario name") {  
        //Skip whatever you want to skip
    } else {
       // Do whatever you normally do
    }

The scenario id is the concatenation of

"<feature name>;<scenario name>",

or in case of scenario outlines, the concatenation of

 "<feature name>;<scenario outline name>;<examples group name>;<table row number>".

Print scenario.getId() out in your before hook so that you know the exact string to look for.

You can also use tags in before hooks .

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