2012-08-03 32 views
3

新建SpecFlowSpecFlow - 未找到一个或多个步骤

如果我设置匹配步骤定义我的考虑,当和随后的场景,不传递参数,一切都工作得很好:

鉴于登录到WebQA

[Given(@"Login to WebQA")] 
    public void LoginToWebQA() 
    { 

所有在网络上阅读的指示,所有我需要做的就是改变属性,包括正则表达式和参数添加到方法如下:

[Given(@"Login to '(.*)'")] 
    public void LoginTo(string url) 
    {enter code here 

但是,当我这样做,重新编译和运行测试,我得到以下错误:

No matching step definition found for one or more steps. 

[绑定] 公共类StepDefinitions { [文(@“登录WebQA “)] 公共无效GivenLoginToWebQA()

预先感谢

回答

4

尝试不单引号:

[Given(@"Login to (.*)")] 
    public void LoginTo(string url) 
    {enter code here 

这里是随机的代码示例我使用:

鉴于某某

当某某

然后导致描述应[测试描述]

[Binding] 
public class AssertionSteps 
{ 
    [Then(@"result description should be (.*)")] 
    public void ThenResultDescriptionShouldBe(string hitDescription) 
    { 
     //here I also clean up the param value to remove [] 
    } 
}