1

当使用 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);
    }
  }
}
4

1 回答 1

0

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

您的步骤具有约束力:

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

它要求绑定:

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

注意后面缺少的空间Url

从绑定定义中删除空间,一切都应该正常。

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

于 2015-05-14T05:19:19.887 回答