Specflow 4 - 捕获组在 Visual Studio 2022 中未绑定

发布于 2025-01-15 01:02:44 字数 1953 浏览 2 评论 0原文

还有其他人在使用捕获组在 Specflow 4 中添加步骤定义时遇到问题吗? 我已将 Specflow 2 的项目更新为使用 Specflow 4 和我的所有步骤定义,包括正确绑定捕获组的定义,并且项目可以按预期运行。但是,如果我创建一个新项目,任何带有捕获组的步骤都会被绑定。

当前平台设置:

Microsoft Visual Studio Community 2022 版本17.1.0 VisualStudio.17.Release/17.1.0+32210.238 微软.NET框架 版本 4.8.04084

安装版本:社区

Node.js 工具 1.5.40105.1 提交 NuGet 包管理器 6.1.0 Visual Studio 中的 NuGet 包管理器。欲了解更多信息 SpecFlow 1.0 的 Visual Studio 扩展

SpecFlow.NUnit:3.9 NUnit3测试适配器:4.1.0 流畅断言:6.2 黄瓜表达式:1.0.6 Selenium.WebDriver.ChromeDriver: 99

这是我的 BDD 脚本

Scenario Outline: A valid user login to a travel website
   Given The home page is displayed
   **When I login as a valid <userType> user**
    Then the dashboard will be displayed
        
        Examples: 
        | userType |
        | agent    |
        | customer |
        | supplier |

我手动将步骤定义添加到我的绑定类中,如下所示,就像我之前一直所做的那样

namespace Holiday
{
    [Binding]
    public class LoginPageStepDefinitions
    {
        [Given("The home page is displayed")]
        public void GivenTheHomePageIsDisplayed()
        {
            throw new PendingStepException();
        }
        [When(@"I login as a valid (agent|customer|supplier) user")]
        public void WhenILoginAsAValidAgentUser(string userType)
        {
            throw new PendingStepException();
        }

        [Then("the dashboard will be displayed")]
        public void ThenTheDashboardWillBeDisplayed()
        {
            throw new PendingStepException();
        }
    }
}

现在,当我返回 BDD 时,我发现该行不是边界。当我右键单击以提供建议的步骤定义时,我得到以下建议:

 [When("I login as a valid agent user")]
 public void WhenILoginAsAValidAgentUser()
 {
    throw new PendingStepException();
 }

我还创建了一个 StepArgumentTransformation 但仍处于未绑定状态。

有谁知道这是否是最新版本的 Specflow 中的错误,或者他们是否删除了此功能?我查看了他们 21 年 11 月发布的 YouTube 视频,他们没有提到捕获组?

非常感谢。

Does anyone else have issues with adding step definitions in Specflow 4 with capture groups?
I've updated a project from Specflow 2 to use Specflow 4 and all my step definitions, including those with capture groups being binded correctly and the project can be run as expected. However if I create a new project, any steps with capture groups are being bound.

Current Platform setup:

Microsoft Visual Studio Community 2022
Version 17.1.0
VisualStudio.17.Release/17.1.0+32210.238
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

Node.js Tools 1.5.40105.1 Commit
NuGet Package Manager 6.1.0
NuGet Package Manager in Visual Studio. For more information about
Visual Studio Extension for SpecFlow 1.0

SpecFlow.NUnit : 3.9
NUnit3TestAdapter: 4.1.0
FluentAssertions: 6.2
CucumberExpressions: 1.0.6
Selenium.WebDriver.ChromeDriver: 99

This is my BDD script

Scenario Outline: A valid user login to a travel website
   Given The home page is displayed
   **When I login as a valid <userType> user**
    Then the dashboard will be displayed
        
        Examples: 
        | userType |
        | agent    |
        | customer |
        | supplier |

I manually add the step definition into my binding class as follows, as I've always done previously

namespace Holiday
{
    [Binding]
    public class LoginPageStepDefinitions
    {
        [Given("The home page is displayed")]
        public void GivenTheHomePageIsDisplayed()
        {
            throw new PendingStepException();
        }
        [When(@"I login as a valid (agent|customer|supplier) user")]
        public void WhenILoginAsAValidAgentUser(string userType)
        {
            throw new PendingStepException();
        }

        [Then("the dashboard will be displayed")]
        public void ThenTheDashboardWillBeDisplayed()
        {
            throw new PendingStepException();
        }
    }
}

Now, when I go back into the BDD, I see that the line isn't bound. When I right click to give me a suggested step definition, I get the following suggestion:

 [When("I login as a valid agent user")]
 public void WhenILoginAsAValidAgentUser()
 {
    throw new PendingStepException();
 }

I've also created a StepArgumentTransformation but still being unbound.

Does anyone know if this a bug in the latest release of Specflow, or have they removed this feature? I've reviewed their youtube video released Nov '21 and their is no mention of capture groups?

Many thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文