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

问题描述

使用下面这行代码,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.

推荐答案

你可以通过在cucumber选项中定义tags值来实现(考虑到你已经在特性文件中对这些场景进行了分组)

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
....

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

08-03 19:49