繁体   English   中英

SpecFlow可重复使用的步骤定义

[英]SpecFlow Re-usable step definitions

有没有办法让SpecFlow重用步骤定义?

在其他工具中,我使用了包含诸如的方法的GivenWhenThen基类

WhenAnOrderIsCreated - 这将通过继承类来使用受保护的订单成员。

似乎无法使用SpecFlow(似乎不喜欢继承)

有没有办法分享各个功能的步骤?

非常感谢

为什么是可能的 - 查看步骤功能的调用步骤( https://specflow.org/documentation/Calling-Steps-from-Step-Definitions/

简而言之,您创建一个继承自以下步骤的步骤定义类:

[Binding]
public class CallingStepsFromStepDefinitionSteps : Steps
{}

然后你可以简单地调用这样的其他步骤:

[Given(@"I am logged in")]
public void GivenIAmLoggedIn()
{
     Given("I am on the index page");
     When("I enter my unsername nad password");
     And("I click the login button");
     incStepCount();
}

我希望我能正确理解你的问题,这是对它的回答

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM