我们在黄瓜中是否有任何注释,它将在功能文件中的任何测试之前运行? [英] Do we have any annotation in cucumber where it will run before any of the tests in the feature file?

查看:15
本文介绍了我们在黄瓜中是否有任何注释,它将在功能文件中的任何测试之前运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@Before 方法将在每个场景之前运行.我们是否有在任何场景之前运行的注释和在所有场景执行后的注释?

@Before method will run before every scenario. Do we have an annotation where it run before any of the scenarion and an annotation after all the scenarios have been executed ?

推荐答案

你可以使用 带有 qaf 的 gerkin,您可以在其中使用不同的 TestNG 侦听器和注释.除此之外,如果您使用 webdriver,您可以获得额外的 驱动程序和元素监听器 支持.例如

You can use gerkin with qaf where you can use different TestNG listeners and annotations. In addition to that if you are using webdriver you can get additional driver and element listeners support. For example

package my.test.pkg
public class MyClass{
    @BeforeSuite
    public void beforeSuite() {
       //get executed before suite
    }

    @BeforeTest
    public void beforeTest() {
       //get executed before each xml test

    }
    @BeforeMethod
    public void beforeMethod() {
       //get executed before each test case/scenario

    }
    @BeforeGroups(["p1","p2"])
    public void beforeMethod() {
       //get executed before group

    }
    //same for after methods @afterXXXXX

 }

你需要在配置文件中添加类:

You need to add class in config file:

<test name="Gherkin-QAF-Test">
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.gherkin.GherkinScenarioFactory" />
      <class name="my.test.pkg.Myclass" />
   </classes>
</test>

此示例未使用侦听器.您还可以使用不同的侦听器.

This example is not using listeners. You also can use different listeners.

这篇关于我们在黄瓜中是否有任何注释,它将在功能文件中的任何测试之前运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆