简体   繁体   English

如何使@Before黄瓜仅限于一个功能文件?

[英]How to make @Before of cucumber restricted for only one feature file?

I am using API testing and selenium both in one framework. 我在一个框架中同时使用API​​测试和硒。 I added @Before of cucumber to open a browser but for api testing i don't need to open browser. 我添加了@Before of Cucumber打开浏览器,但是对于api测试,我不需要打开浏览器。 But its opening for both UI and API. 但是它同时针对UI和API开放。 How should i restrict so that browser doesn't open up for api? 我应该如何限制浏览器才能使用api? @Before is opening browser for api also which i don't need. @Before正在打开我不需要的API浏览器。

You can use tagged hooks on the Before hook 您可以在Before钩子上使用标记的钩子

@Before("not @API")
public void before() {
    ....
}

Add the tag @API to the feature file with api senarios. 使用api senarios将标签@API添加到功能文件中。

@API
Feature: api feature file

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

相关问题 Cucumber 只运行一个功能文件,忽略其余的 - Cucumber run only one feature file and ignore the rest 在运行之前在Java中修改黄瓜功能文件 - Modify cucumber feature file in Java before running it 如何在黄瓜的特征文件中进行迭代 - How to iterate in feature file of cucumber 在黄瓜功能文件中仅执行一次@Given - Execute @Given only once in cucumber feature file 如何重复使用黄瓜功能文件中所述的相同功能 - How can I make repeated use of a same feature described in cucumber feature file 如果 Cucumber 特征文件中有 1000 个特征文件,我只想执行偶数个特征文件。 怎么做? - If there are 1000 features files in Cucumber feature file and I want to execute only even feature files. how to do that? 并行运行 cucumber 功能文件中的场景,一次一个功能文件 - Run scenarios in a cucumber feature file in parallel, one feature file at a time cucumber特征文件中如何给多个参数 - How to give multiple parameters in the cucumber feature file 如何在java或groovy中解析Cucumber特征文件? - How to parse Cucumber feature file in java or groovy? 如何从Jenkins读取Cucumber功能文件 - How to read Cucumber feature file from Jenkins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM