【问题标题】:SpecFlow - No matching step definition found for one or more stepsSpecFlow - 没有为一个或多个步骤找到匹配的步骤定义
【发布时间】:2013-03-06 17:30:04
【问题描述】:

SpecFlow 新手

如果我设置了我的 Given、When 和 Then 场景并且不传递参数,那么一切正常:

鉴于登录到 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()

提前致谢

【问题讨论】:

    标签: .net bdd specflow


    【解决方案1】:

    尝试不使用单引号:

     [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 []
        }   
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-26
      • 2018-06-20
      • 2017-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多