【问题标题】:Techtalk.Specrun.PendingTestException: No matching step definition found for one or more stepsTechtalk.Specrun.PendingTestException:没有为一个或多个步骤找到匹配的步骤定义
【发布时间】:2015-05-16 09:27:26
【问题描述】:

当使用 Spec Flow 并运行已在其背后实现代码的功能文件时,我看到:

Techtalk.Specrun.PendingTestException:没有为一个或多个步骤找到匹配的步骤定义

我在每个功能背后都有代码,无论我尝试什么,我都会不断收到待处理的输出。

例如

Given I browse to Url "http;//www.google.co.uk"
-> No matching step found for the step definition
[Given(@"I browse to Url""(.*)""")]
Public void GivenIBrowseToUrl(String p0)
{
  ScenarioContext.Current.Pending();
}

但是我为此功能实现的代码如下:

using System;
using System.Diagnostics;
using TechTalk.SpecFlow;

namespace UserJourney
{
[Binding]
  public class PhoneJourneySteps
  {
    [Given(@"I browser to Url ""(.*)""")]
    public void GivenIBrowserToUrl(string url)
    {
        Process.Start(url);
    }
  }
}

【问题讨论】:

  • 你的问题在哪里?

标签: specflow specrun


【解决方案1】:

您的问题是,正如错误消息告诉您的那样,您没有正确绑定的步骤。

您的步骤具有约束力:

[Given(@"I browser to Url ""(.*)""")]

它要求绑定:

[Given(@"I browse to Url""(.*)""")]

注意Url后面的空格吗?

从绑定定义中删除空格,一切都会正常。

另外,我建议在场景文件的步骤中使用单引号,它使绑定更易于阅读。 Given I browse to the Url'http://google.com/'也是如此

【讨论】:

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