本文介绍了如何使用CucumberRunner类运行多个功能文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用下面的代码行,可以执行login.feature中提到的所有方案。

Using the below line of code, all scenarios mentioned in login.feature can be executed.

@CucumberOptions(features= "src/main/resources/publish/login.feature", format = {"pretty"} )

如果必须执行多个功能文件,该如何定义?假设我定义如下,将执行发布文件夹中提到的功能。

If I have to execute multiple feature files, how do I define? Assuming if I define as below, features mentioned in publish folder would be executed.

@CucumberOptions(features= "src/main/resources/publish", format = {"pretty"} )

如果我必须运行多个功能并里面的场景,我该如何定义?我是否必须创建多个 cucumberRunner 类,还是可以在一个类文件中进行定义?

If I have to run multiple features and scenarios inside it, how do I define? Do i have to create multile cucumberRunner classes or i can define in one class file.

推荐答案

您可以通过在黄瓜选项中定义标签值来做到这一点(考虑到您已经将这些方案分组在功能文件中)

You can do it by defining tags value in cucumber option(considering that you have already grouped those scenarios in feature files)

例如:
features = src / test / resources / FeatureFiles,tags = @ feature1scenariogroup1,@ feature2cenariogroup2

Eg: features="src/test/resources/FeatureFiles",tags="@feature1scenariogroup1,@feature2cenariogroup2"

在功能文件中定义标签:

Defining Tags Inside Feature File:

Feature: My Feature File
@smoke
Scenario: Login
Given I open "FireFox" browser
When I navigate to Sectionone "Home" page
And i do something
Then I Validate Something

@regression
Scenario: Compose Email
Given I open "FireFox" browser
When I Do An Action

@OnlyOneTime
Scenario:Send Email
....

这篇关于如何使用CucumberRunner类运行多个功能文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:15