如何使用具有 testng 功能的 QAF BDD 和 Gherkin

How to utilize QAF BDD and Gherkin with testng features

我已通过 java 个步骤成功地将具有所需配置的 QAF BDD API 添加到 运行 个功能文件。 我当前的项目利用 TestNG 侦听器和注释来设置 Base 类,并为脚本执行预设其他所需的数据。如何配置可用的适配器 and/or 插件以便完全识别 TestNG 功能?

I found this project avaible from qmetry: [https://github.com/qmetry/qaf-cucumber]

Are there samples on how to use it? Your help much appreciated!

使用 QAF,您应该能够利用所有 TestNG 功能。

使用 BDD 时,您需要将带有注释的配置方法移动到相应的 testng 侦听器中。例如,可以将带有 Before/AfterSuite 注释的方法移至套件侦听器,将 Before/AfterMethod 移至方法调用侦听器。您可以使用任何方式 register listeners.

另一个替代方法是,您可以使用 class 套件测试和组的配置方法。例如 class 和 Before/After Test/Suite/Groups 带有注释的方法(可能您需要添加启用 false 的虚拟测试方法)。将 class 与工厂 class 一起添加到 xml 配置文件中。

它将不支持@Befor/afterClass 和Befor/AfterMethod,因为您没有为测试用例创建class。你仍然可以通过方法调用监听器来实现它。

当您使用 QAF 时,您可能不需要很多驱动程序管理代码,因为 qaf 提供了线程安全驱动程序和资源管理的内置功能。您可以利用 driver and element listeners and locator repository features. It is highly configurable, for example you can set property selenium.singletone 来指定驱动程序实例范围。可能的值可以是 Tests (testng xml test) 或 Methods (test mtehod) 或 Groups.

QAF-cucumber 是为那些想要使用 Cucumber runner 而不是 TestNG 或想要通过 TestNG 使用 Cucumber 步骤实现的人提供的支持库。