有没有办法让 SpecFlow 重用步骤定义?
在其他工具中,我使用了 GivenWhenThen 基类,其中包含如下方法
WhenAnOrderIsCreated -- 这会初始化一个 protected 订单成员,供继承类使用。
似乎无法与 SpecFlow 一起使用(似乎不喜欢继承)
有没有办法跨功能共享步骤?
非常感谢
最佳答案
为什么是的,这是可能的 - 从步骤功能 (https://specflow.org/documentation/Calling-Steps-from-Step-Definitions/) 检查调用步骤
简而言之,您创建了一个继承自 Steps 的步骤定义类:
[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();
}
我希望我正确理解了你的问题并且这是对它的回答
关于c# - SpecFlow 可重用步骤定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5228030/