gpt4 book ai didi

specflow - 使用 SpecFlow 定义特征范围的步骤?

转载 作者:行者123 更新时间:2023-12-02 14:32:06 25 4
gpt4 key购买 nike

我正在使用 SpecFlow 进行一些 BDD 式测试。我的一些功能是 UI 测试,所以他们使用 WatiN。有些不是 UI 测试,所以它们不是。

目前,我有一个 StepDefinitions.cs 文件,涵盖了我的所有功能。我有一个 BeforeScenario 步骤来初始化 WatiN。这意味着我的所有测试都会启动 Internet Explorer,无论是否需要。

SpecFlow 中是否有任何方法可以将特定的特征文件与一组特定的步骤定义相关联?或者我是从错误的角度来处理这个问题的?

最佳答案

如果您使用标签,有一个简单的解决方案可以解决您的问题。

首先标记您的功能文件以指示特定功能需要像这样的 WatiN:

Feature: Save Proportion Of Sample Pool Required
As an <User>
I want to <Configure size of the Sample required>
so that <I can advise the deployment team of resourcing requirments>.

@WatiN
Scenario: Save valid sample size mid range
Given the user enters 10 as sample size
When the user selects save
Then the value is stored

然后用指示标记的属性装饰 BeforeScenario 绑定(bind):

[BeforeScenario("WatiN")]
public void BeforeScenario()
{
...
}

只有使用 WatiN 的功能才会调用此 BeforeScenario 方法。

关于specflow - 使用 SpecFlow 定义特征范围的步骤?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2943625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com