C# Specflow不识别步骤

C# Specflow不识别步骤,c#,.net,specflow,C#,.net,Specflow,当 When Request for servername 'someurl.com/szhm04c4.xml' is processed 当我按F12时,Visual Studio告诉我可以复制以下步骤定义: [When(@"Request for servername '(.*)' is processed")] public void WhenRequestForServernameIsProcessed(string p0) { ScenarioContext.Current.

When Request for servername 'someurl.com/szhm04c4.xml' is processed
当我按F12时,Visual Studio告诉我可以复制以下步骤定义:

[When(@"Request for servername '(.*)' is processed")]
public void WhenRequestForServernameIsProcessed(string p0)
{
    ScenarioContext.Current.Pending();
}
我将其粘贴到我的step文件中,该文件继承自
Steps
,并实现它

public void WhenRequestForServernameIsProcessed(string servername)
{
    var httpRequest = this.Bootstrapper.GetFake<IHttpRequest>();
    A.CallTo(() => httpRequest.Path).Returns(servername);

    var httpContext = this.Bootstrapper.Get<IHttpContext>();

    this.Bootstrapper.Get<IHostRequest>().Process(httpContext);
}
public void当处理服务器名请求时(字符串servername)
{
var httpRequest=this.Bootstrapper.getfalse();
A.CallTo(()=>httpRequest.Path).Returns(servername);
var httpContext=this.Bootstrapper.Get();
this.Bootstrapper.Get().Process(httpContext);
}
当我执行测试时,它失败了,我得到以下错误消息:

TechTalk.SpecFlow.SpecFlowException测试挂起:无匹配步骤 找到一个或多个步骤的定义。使用制度;使用 TechTalk.SpecFlow

名称空间MyNamespace{ [有约束力] 公共类定义 { [处理(@“服务器名请求”(.*)”时]]处理服务器名请求时公共无效(字符串p0){ ScenarioContext.Current.Pending();} }}

为什么呢?我确实定义了这个步骤


提前感谢

您必须将[Binding]属性添加到类中,这样SpecFlow才能找到您的步骤。

您必须将[Binding]属性添加到类中,这样SpecFlow才能找到您的步骤。

当属性添加到您的步骤代码中时,您的步骤代码是否具有
属性?您的绑定类是否具有[Binding]你说什么?谢谢你![Binding]属性丢失,如果您愿意,您可以将此添加为答案,然后我将标记为已解决:-)相关帖子-您的介入代码上是否有
When
属性?您的绑定类上是否有[Binding]属性?谢谢!缺少[Binding]属性,如果需要,可以将其添加为答案,然后我将标记为已解决:-)相关帖子-