我有一个包含以下内容的specflow特征文件When
When Request for servername 'someurl.com/szhm04c4.xml' is processed
Run Code Online (Sandbox Code Playgroud)
当我按F12Visual Studio 时,我会告诉我可以复制以下步骤定义:
[When(@"Request for servername '(.*)' is processed")]
public void WhenRequestForServernameIsProcessed(string p0)
{
ScenarioContext.Current.Pending();
}
Run Code Online (Sandbox Code Playgroud)
我将其粘贴到继承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);
}
Run Code Online (Sandbox Code Playgroud)
当我执行测试时,它失败并收到以下错误消息:
TechTalk.SpecFlow.SpecFlowException 测试待决:未找到一个或多个步骤的匹配步骤定义。使用系统;使用 TechTalk.SpecFlow;
命名空间 MyNamespace { [Binding] public class StepDefinitions { [When(@"对服务器名称'(.*)'的请求已处理")] public void WhenRequestForServernameIsProcessed(string p0) { ScenarioContext.Current.Pending(); } } } }
这是为什么?我确实定义了这一步......
提前致谢