0

早上好。

我遇到了 SpecFlow 的问题,我不知道如何解决它。将不胜感激任何帮助。所以...

让我们看一个简单的 SpecFlow 功能:

Given the JoeDoe user is associated to an existing staff account with the following information
  | Field       | Value         |
  | First Name  | Joe           |
  | Last Name   | Doe           |

它连接到以下步骤:

        [Given(@"the JoeDoe user is associated to an existing staff account with the following information")]
        public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(Table table)
       {
        ...logic
       }

但是,一旦我更改步骤以接受来自 Feature 的参数,如下所示:

        [Given(@"the (*.) user is associated to an existing staff account with the following information")]
        public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table)
       {
       ...logic
       }

功能到步骤的链接中断。从那时起,如果我在功能中按F12(或转到 Step Definition),Visual Studio 会告诉我没有匹配的步骤,并且:

“未找到此步骤的匹配步骤绑定!是否要将绑定骨架复制到剪贴板?”

当然,测试场景没有运行。

这是怎么回事?我似乎做的一切都是正确的。

4

1 回答 1

2

你有没有尝试过:

    [Given(@"the (.*) user is associated to an existing staff account with the following information")]
    public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table)
   {
   ...logic
   }

它应该(.*)代替(*.).

于 2012-04-04T19:04:32.883 回答