早上好。
我遇到了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
}
功能到步骤链接中断。从那时起,如果我从featere中按 F12 (或转到步骤定义),Visual Studio会告诉我没有匹配步骤,并且:
“此步骤找不到匹配的步骤绑定!是否要将绑定骨架复制到剪贴板?”
当然测试场景没有运行。
发生了什么事?我似乎正在做正确的事。
答案 0 :(得分:2)
你试过了吗?
[Given(@"the (.*) user is associated to an existing staff account with the following information")]
public void GivenTheJoeDoeUserIsAssociatedToAnExistingStaffAccountWithTheFollowingInformation(string userName, Table table)
{
...logic
}
应该是(.*)
而不是(*.)
。